From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 590D8C27C77 for ; Fri, 14 Jun 2024 14:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HsDJYiLq/4nFSmLSCvZ8wEP0k6D/S7qVLaBxPe9kdrw=; b=bNnCuhCH093xNj6oQ62Nfue1dE ZJjBAxc36oocphBrHlDRVBVRxWkmfrPxbSXZcR8ZLBqAtvR/+cUJLxb6lkwqJt+F9p9wdHRQCS4p6 pZsCPs2pZWRCk2i7q8QUhe6BBpB/4lZN9q2nf0fhrUXqi2FkUeasjkw7V96J9YFxcYvxmxw0uUp1C QVUOqL8cSfOXzvZ/CmMGjAr81A4sEiuEcMQjRUcq7op8om9yge3sgOnFR/P3N4T56qD1f5kqkOwIT f6ZYKEOxldsyQSdVxTunR99DsOncHAVVUgz+LzLdSWQoDQmZTZqWGIBiurJfrW7ExOnXSDEZnUGKf tEC6frGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI895-000000034UJ-14Pc; Fri, 14 Jun 2024 14:43:15 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI891-000000034TT-1RQD; Fri, 14 Jun 2024 14:43:12 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 577FF2E0; Fri, 14 Jun 2024 16:42:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718376174; bh=2Mm4o+0/5Q+FxRwCZ5j72NsmFJaPx4lp4liZ9IiL+B0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JX0T1pnHQTq1dT3dHjsdQJWX9axFEh0RCtT/qRXDMIK0zdDry4iAYraihPEa31OA4 jCEEHsL4kg5r97DlJx2XokbFqZFjelM1lsINw1FIAVHkPDp4uCOUSyJ+DWgFNsd0Xq 0q+oPotxXSCbUSmLfOmdYJopWwIl1/px6WH4DdUU= Date: Fri, 14 Jun 2024 17:42:48 +0300 From: Laurent Pinchart To: Julien Stephan Cc: AngeloGioacchino Del Regno , Louis Kuo , Phi-bang Nguyen , Florian Sylvestre , Andy Hsieh , Conor Dooley , devicetree@vger.kernel.org, Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-media@vger.kernel.org, Matthias Brugger , Mauro Carvalho Chehab , Paul Elder , Rob Herring Subject: Re: [PATCH v4 3/5] media: platform: mediatek: isp_30: add mediatek ISP3.0 sensor interface Message-ID: <20240614144248.GA20136@pendragon.ideasonboard.com> References: <20240110141443.364655-1-jstephan@baylibre.com> <20240110141443.364655-4-jstephan@baylibre.com> <3c2bee40-3792-409c-b42f-f8b013ff641c@collabora.com> <53838e76-bfa4-41f5-a015-a37472e98991@collabora.com> <20240614123345.GN6019@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240614_074311_550172_32375FE1 X-CRM114-Status: GOOD ( 41.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Julien, On Fri, Jun 14, 2024 at 04:14:52PM +0200, Julien Stephan wrote: > Le ven. 14 juin 2024 à 14:34, Laurent Pinchart a écrit : > > On Fri, Jun 14, 2024 at 12:38:15PM +0200, Julien Stephan wrote: > > > Le mer. 12 juin 2024 à 10:06, AngeloGioacchino Del Regno a écrit : > > > > > > > > Il 10/06/24 16:39, Julien Stephan ha scritto: > > > [...] > > > > >> > > > > >>> + writel(0x10001, input->base + SENINF_TG1_SEN_CK); > > > > >> > > > > >> Unroll this one... this is the TG1 sensor clock divider. > > > > >> > > > > >> CLKFL GENMASK(5, 0) > > > > >> CLKRS GENMASK(13, 8) > > > > >> CLKCNT GENMASK(21,16) > > > > >> > > > > >> Like this, I don't get what you're trying to set, because you're using a fixed > > > > >> sensor clock rate, meaning that only a handful of camera sensors will be usable. > > > > >> > > > > >> Is this 8Mhz? 16? 24? what? :-) > > > > >> > > > > >> Two hints: > > > > >> - sensor_clk = clk_get_rate(isp_clk) / (tg1_sen_ck_clkcnt + 1); > > > > >> - int mtk_seninf_set_sensor_clk(u8 rate_mhz); > > > > >> > > > > >> Please :-) > > > > > > > > > > Hi Angelo, > > > > > > > > > > I think I get your point about not hardcoding the sensor rate, but I > > > > > am not sure how to use > > > > > a mtk_seninf_set_sensor_clk(u8 rate_mhz); function. > > > > > > > > > > Where would it be called? How is it exposed to the user? > > > > > > > > > > > > > As for where: setup, streaming start, resolution change (which may be covered > > > > by streaming start anyway, as a change should be calling stop->start anyway). > > > > > > > > And for the how is it exposed to the user - well, depends what you mean for user, > > > > but it's all standard V4L2 API :-) > > > > > > > > Last but not least, I can give you another hint.... > > > > > > > > struct media_entity *entity = (something_here); > > > > struct media_pad *mpad; > > > > struct v4l2_subdev *cam_subdev; > > > > struct v4l2_ctrl *ctl; > > > > s64 link_frequency, pixel_clock; > > > > > > > > if (entity->pads[0].flags & MEDIA_PAD_FL_SINK) > > > > return -E_NOT_A_CAMERA_SENSOR_WE_IGNORE_THIS_ONE; > > > > > > > > pad = media_pad_remote_pad_first(&entity->pads[0]); > > > > if (!pad) > > > > return -ENOENT; > > > > > > > > if (!is_media_entity_v4l2_subdev(pad->entity)) > > > > return -ENOENT; > > > > > > > > if (pad->entity->function != MEDIA_ENT_F_CAM_SENSOR) > > > > return -ENOENT; > > > > > > > > > > Hi Angelo, > > > > > > Thank you for the detailed explanation :) > > > However, I can't make it work because in my case, seninf is connected > > > to an external ISP > > > so pad->entity->function == MEDIA_ENT_F_PROC_VIDEO_ISP. > > > > > > How can I get the pad corresponding to the sensor? > > > > You don't have to. You can drop that check, and get the link frequency > > of the source subdev with v4l2_get_link_freq(), whatever it is. > > > > > > cam_subdev = media_entity_to_v4l2_subdev(pad->entity); > > > > ctl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_PIXEL_RATE); > > > > > > Is this mandatory to implement V4L2_CID_PIXEL_RATE ? > > > Should I return an error if not found? > > > > Does SENINF need to know both the pixel rate and link frequency ? > > V4L2_CID_PIXEL_RATE is very ill-defined, at the moment it only makes > > sense as a value relative to the sensor pixel array, and doesn't really > > apply further down in the pipeline. What information do you need to > > program the SENINF ? > > Hi Laurent, > > I need to know the clock divider for the sensor Could you provide some details on how the SENINF uses that divisor ? What does it control, and what are the constraints ? > > > > /* multiplier is usually bits per pixel, divider is usually num of lanes */ > > > > link_frequency = v4l2_get_link_freq(cam_subdev->ctrl_handler, multiplier, divider); > > > > pixel_clock = v4l2_ctrl_g_ctrl_int64(ctl); > > > > > > How to know the sensor clock given link_frequency and pixel_clock? > > > Can you point me to drivers doing something similar? > > > > > > > > > > > ....now you know what the sensor wants, set the seninf sensor clock accordingly. > > > > > > > > Cheers > > > > Angelo > > > > > > > [...] -- Regards, Laurent Pinchart