Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp849081lqs; Fri, 14 Jun 2024 07:26:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJE/u5+hLO2PmFtGuiFWpXOPQGo7n/ZJ++xcH6EnxHtCR1SF4dmiXV8q+pHIH+m2LtXqvYJiaWk/hzAD2aAuckehYGsyrfDrBvTWNxPQ== X-Google-Smtp-Source: AGHT+IHGUJ6GRUhWvPEgY58y2hsrWIKYYKm7yHPGbogWFEF/CFY3zzb+aixV1U+k/wFOZOaVzeUy X-Received: by 2002:a17:902:d2ca:b0:1f6:9122:2c2 with SMTP id d9443c01a7336-1f8626d193bmr29407455ad.15.1718375167867; Fri, 14 Jun 2024 07:26:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718375167; cv=pass; d=google.com; s=arc-20160816; b=pIFuxwpSsM4wyMVG6Ges92rs6OmtHROXJ1VMfNmQycqKg1R83URlhEm3Tjjm17gO8b Sbktga3cAfZg7RcrwtlUb4SJtFy8FgEbzOJSF42JIAmu2fpV9K4PhLpepqvl0f2yu+pk sxLoeNeoZc3nHcyMknKWto2X4dBufckenCZWl7k/GuIjZfrTdbaPgB1upuCzfOX97d3H y7mS2woEI8Tp7AIe/LXCdTySddyuzVFG4R71hh8aXET8AEsYxektIpzuy0+ozT8JgIDt GEgOX5PzMJtehZhDfzWHuncYStqHiuN2gGmYOIC1LbsMBg9WjPzOjnJn7TKJdhs22Vm3 ooLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=QR9tmd+yNNNniijbyRPGMlyIsNhlrnteAwcBJgKWpb4=; fh=0ds50InqWgyg1XV0+G9VjGemEa//OonX0p4g0cZbTmo=; b=yP1o4r7NPtRjH/xuq3mGEZh2KrI5jg+dPg7B7+NhDpMuNQU9C2gRkH1aHJeavqOsgH VrF4MMPR+bF+/D2YJSi1EECbGDd2HQni6pEPey7hEmMO+KGfupr0DZSGA8wm22pXs2SZ DKdSa8LWR037/mDH5mHKFc5+BV0881rSgMormk+dONAGBO/oSz43uSCWJ+WFU6STWF3x 9fsEgWsE3Az/EVF/svVmTXWps8zRF9fKuMCHqLPywUP4WyGtgpY29VtQQa8bak0w7VVT zgMmO9+heg6RNpe43zjwgHaIOWHiOc/Mn1jHEJcqktzF9iTi0/L++EqThHPQhUhqpd7Z Y6SQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="GhC/vQi3"; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-214997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214997-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f855ee2d0csi37109365ad.334.2024.06.14.07.26.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 07:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="GhC/vQi3"; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-214997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214997-linux.lists.archive=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 82346B26368 for ; Fri, 14 Jun 2024 14:15:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E3C3125D6; Fri, 14 Jun 2024 14:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="GhC/vQi3" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C98319460 for ; Fri, 14 Jun 2024 14:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718374508; cv=none; b=GSshKBCEAhXZyTbBLnwfHUkCRv/rbqXThmDXsnwjNKgYfEBfJsNdFLdtuD93A6pRJMPgOdqkMv/pOSifYmZGeMBawaL85X7X88GPKlyUAi9xs6TKeTiOa7iSk1QB9A2cZ4Q0JuP2+kPjZ31KQtEsGgbk8E/d/jfoqvNwE4h3uyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718374508; c=relaxed/simple; bh=GdMJCTJPK6ZUOBTwouwEkqIoqIipuR0n2OyhocBfnN8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=O6dJHDIbRGgcH4iAFjXAxEJanrqVZnqvkqmwBC8Ldkr46nPTJ9uBhQh5srXkshplXjzdmusLrWkBn+Wr+se9WN4WSSn8sbWdESHa3PfZevCfRA3bEcAuqzzI95+WRbt6clojGTTmhySAUDljaPv1Muomqvb7u7rPdjRqs6M1s4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=GhC/vQi3; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-57c923e03caso2491557a12.3 for ; Fri, 14 Jun 2024 07:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718374504; x=1718979304; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QR9tmd+yNNNniijbyRPGMlyIsNhlrnteAwcBJgKWpb4=; b=GhC/vQi35vCRnwHiG6wc3dV4jR0tg1UqwQ1rbMn9GlurauP07W2/uFOd3yEdrn3zPU hPoGhLEysYvN6qKJ6c0jEYj4Ui0W/wDVeYk7ElM7+FrWgpHiX+Orva6cZOsg9FWLlWcV GzG5thr7XA11pUF9Tmu4zBJX9tHcFqGolhZlbnmte+YmjWDEHfiYB/7oHQBD06Z3c6Zo uqJ9tt+ExDpV4N0P5rpdgBo84ofRH7P6Und9FG702mQ01iCkNPSk78nHl0OZCmgLpKDE zZKbJiu6IUYfKsmE5i8a0L+q/CJ24/bOhLJsxOOjRWFEMkwZxrRzQYYVJCZlLTyOznj2 IrmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718374504; x=1718979304; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QR9tmd+yNNNniijbyRPGMlyIsNhlrnteAwcBJgKWpb4=; b=emKO8V48q0T3ZeIknxksmUTDXL3J+96A0l1AMrTP9M0t8HQdNbB/PCej1K6NJvhHix Nbzfp95hiLUXCLZestT69d/dpVYYN236GGCWIagfMMc8TpmPGF7GHHQLx4VKoMnU1+LV iDClx+pknjBOsnnX1A5TkRtqPm+1dCNoMsziIRuCfMXh/jE5tiB9Oh7E6CImyUfC46c9 SYbNVgla5pl8CZRvMC4MkX4s1Z/194VwqYyyiUoVpMbcKSUOkoDS8bt7Z2/janu7anY0 qIouritYZX6eXkTBbXmoVaPvWgqego4V0RydrQAFHIGA9T7vPy5bYBQtAY6jf+nt1rhq pdEQ== X-Forwarded-Encrypted: i=1; AJvYcCUJHFqhs4EUeQvYIC0iztXWusF6lBIXQywdskLhXTH8qXc62b7WtRAjrtvEhEKfL7b6msgYsH1VQqQJYplJS3lEZcJoyQOe3BkRBRZT X-Gm-Message-State: AOJu0Yw5WzvIlRHbBMSafjmsMsRWz2Cz++/2WZh03sv+AbLlXY+8krur JP6JQwNE+gF1h9po5u7UTCegx5DvmdJu9P4PEWve6dZfR5RjjRGLLtT9Mo29h/S1gshvtQBY8fk Bc3HyfU3rC764Q7xCp7iJdCOM4QzsZny4K6IscQ== X-Received: by 2002:a17:906:34d9:b0:a6f:15a3:b085 with SMTP id a640c23a62f3a-a6f60dc5539mr173229766b.51.1718374503888; Fri, 14 Jun 2024 07:15:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> In-Reply-To: <20240614123345.GN6019@pendragon.ideasonboard.com> From: Julien Stephan Date: Fri, 14 Jun 2024 16:14:52 +0200 Message-ID: Subject: Re: [PATCH v4 3/5] media: platform: mediatek: isp_30: add mediatek ISP3.0 sensor interface To: Laurent Pinchart 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le ven. 14 juin 2024 =C3=A0 14:34, Laurent Pinchart a =C3=A9crit : > > On Fri, Jun 14, 2024 at 12:38:15PM +0200, Julien Stephan wrote: > > Le mer. 12 juin 2024 =C3=A0 10:06, AngeloGioacchino Del Regno a =C3=A9c= rit : > > > > > > 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 u= sing a fixed > > > >> sensor clock rate, meaning that only a handful of camera sensors w= ill be usable. > > > >> > > > >> Is this 8Mhz? 16? 24? what? :-) > > > >> > > > >> Two hints: > > > >> - sensor_clk =3D 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 me= an for user, > > > but it's all standard V4L2 API :-) > > > > > > Last but not least, I can give you another hint.... > > > > > > struct media_entity *entity =3D (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 =3D 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 !=3D 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 =3D=3D 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 =3D media_entity_to_v4l2_subdev(pad->entity); > > > ctl =3D 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 Cheers Julien > > > /* multiplier is usually bits per pixel, divider is usually num of la= nes */ > > > link_frequency =3D v4l2_get_link_freq(cam_subdev->ctrl_handler, multi= plier, divider); > > > pixel_clock =3D 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 a= ccordingly. > > > > > > Cheers > > > Angelo > > > > > [...] > > -- > Regards, > > Laurent Pinchart