Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp865907lqs; Fri, 14 Jun 2024 07:55:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2WtLRERQ4LGJUuBVkx932raAU91EUWnm023UaVGVRmgtKw9QgKL4/M2/cf8d764HhySqGpfVstSmAUZSgrx2An/vh0ApxKhsgZFfrfQ== X-Google-Smtp-Source: AGHT+IGWvMCHLzC8Wnq1i62ndUVjkBZukKaCT6IdmrokHocozXK51EDpkD52vKhT9igWp2T4JUKI X-Received: by 2002:a17:90a:d3ca:b0:2c4:f32c:6b with SMTP id 98e67ed59e1d1-2c4f32c012fmr1323137a91.19.1718376918362; Fri, 14 Jun 2024 07:55:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718376918; cv=pass; d=google.com; s=arc-20160816; b=JjcsYeHtBuxJ41w0AcsQfGRhFL3aP57H0Oibu437YNP3+bILwAmwRTsBQZ7uueh+wD 5bwf0amxrYPPr2WZZoiwg/Pho7cMluP7sjFRY3zilwzboU5kPBWJ2hJR4GZRYaW98D5e KTNUDfQVHuidd5gNUEbzFIBUGqJz72tI4YTKCgCtOPWcR+lOHPJrD2TzL+njdEr4axWD MKoXd/H0guU5yQk0PZTOUb2ooiy5lgSjQX2fx9qGN60AUlbz1uMhgBYQtXiwcEvcf/fn JHSFbnBRg2bJ8diLLyh/YAIrkAibBtZvQUTd1960HEu/JTH4oeX45kpxRX8y5OuZk5HB A5fQ== 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=SdyE64ITlsEjDYdjWbst/sH7Q92347D+3IPnUE30Q5I=; fh=PH64p9m7xQJAQdVthbzcYI+Hpmwrcd3NTSm7EMEyKt8=; b=br3322ZJ0v/8i91Iqxxm7Pc5fHgMIRHqwivKfe+91zcbS6FMm9c5RTLA68puxxvSQG N2o1zlx5F+0qQso6bz7sETTykZ4ZVOujjiS1dppXmCD/o7G7riacJ/p7K4HZAdfD8XjI Hj8y/RQtUyl2Tx9zZZrXOsIBNGznKaEcwEIVPfABqz/SjJj6L0KM7XAGvkJW+2L8EYP+ Tu8C9XrXI6ZyNkDKlFWe8mpOQYJCr5A98ettwMyC+NsLlh6tkKfECEbfIp1VmP7NwbB6 V2tdK0Y9pjHoZxE3jXv9UvZbOgAjIjNhfWVXJwIECyamp/O/MHx1oc0ZlB0iPdbEXq2m ciKg==; 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=e0peMdVP; 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-215054-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215054-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee453f6e1si3661987a12.572.2024.06.14.07.55.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 07:55:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215054-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=e0peMdVP; 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-215054-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215054-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6C47C2842C8 for ; Fri, 14 Jun 2024 14:55:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E3DA17BCD; Fri, 14 Jun 2024 14:55:03 +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="e0peMdVP" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 178B420DC5 for ; Fri, 14 Jun 2024 14:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718376902; cv=none; b=r93nx05DrUomUjsJTU0AXcSdz4y5W+qIP+HdEf4j84cVB8lq3Z+091+r48DnJMQuJwogwtPgjqade9ZCimaRM7GUA9Z0aNB3+CoXqW6eLdeLztbSk7Ymm4KV+Yqpp+EkSoy5Z8fsyXKAD2rw/rYLGuzG2DAbmjrp/g/3HlR95uQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718376902; c=relaxed/simple; bh=ePyV2mgKNple3T7qBgOKPNX3ONHppQL/WQz9ZOXDXTM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VfJmw62Loyyi9v/TNX9jkK7cC3c4katTjVnJQkYbPHH/AEB4B30vHqDGCGqX7QX4SeEPba4SzdmrV3aMbjq+tNXdcP3dOniuw5lbowTIYzl1Z4RoiRsQiUrxIB06bzeZ6rMv3kl7Qd802liQE3m4Y2jIknqQVkxEDDqQdhqp8rY= 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=e0peMdVP; arc=none smtp.client-ip=209.85.218.53 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-ej1-f53.google.com with SMTP id a640c23a62f3a-a6265d48ec3so325329466b.0 for ; Fri, 14 Jun 2024 07:54:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718376898; x=1718981698; 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=SdyE64ITlsEjDYdjWbst/sH7Q92347D+3IPnUE30Q5I=; b=e0peMdVP5479tPlYB/HEntbs+UH/zRTVbfvSTpsk4aZKAPs51G4lc/EJRGYHs19VL1 w9J8vEyXb6NLj2V7vM5uaMFjB2DHPxBhuRotkmTUNJkWaRQ3EJT69y08xA4J/AXSc8wo IC2hXkEzzeA7CirLK/+MKTC1Zo7ALbHNeAq8QEr3WNbM5utLZmPwsDf4KCRWQaTiMDZ8 CIj98OI9DpqCer3lCQ4iad9UekDDbmmL6iOjjGDGW640tQbbGlaAzql6QoqUD8oLuizk mN8d1DaJrQ5GlqlXXDbNC68OqSkQVsWzhKU9PDuYfsz+B2P8JyFSPTSG4hhRWpfTwR/i 4lhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718376898; x=1718981698; 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=SdyE64ITlsEjDYdjWbst/sH7Q92347D+3IPnUE30Q5I=; b=UL8Su0JAoxUvgEkJaynQ2p64ZNzNLYbPDMohBnzPoG5nm/J3Vyjn2hcMWiLg7L1iZL RStHu9+FzjsYKFWOXVHRHPTGpU88tKJcsJCcZERBrub4UpYareZ+q2Sa/+TqJoX2M1kc MbujcVqFKpN1E4hy1L9U/oXFsHADp+GnkJVJliUA64W1GSjJNYBXa80CmKkvuK1wI1E0 wsuLG8sm6Y6Ur/w/6FWBSViRwk7BZqQewtVznrg97pG253wfYAHDSUyUTnShKjqWiGFb uXi1dL4ZS7VfQxaiF3kXMKwFkzp+1w7rTF5QXdS6tVYUnDy5P4TgMroiJ6brTSYhGCm6 ZSuA== X-Forwarded-Encrypted: i=1; AJvYcCWccv2R6UXcVe8yb9eLgzok0XnsYHVhbw4geGvOhOqMtFVmaO3gtgwbQvsmwAhd+YcOzvZCahFhwuRYPxqAJz7kry2AZvq5qeEPmPDu X-Gm-Message-State: AOJu0YxhQDPY/v6Wza8ZHCz8r1QrCWfL7VOBm6HQZE3h1tifmDYMbrN+ XmOsateOfN8Xe1PwOnl0HatvJvgseSvQepJWTPKiFUlTIdG4AVEd00I2i5z1KeCa+EUyMsKZHd2 mmbajRV8N0L6EvXTpwte8CuhJm5iLOp5ANMQKpw== X-Received: by 2002:a17:907:d312:b0:a6f:668b:3434 with SMTP id a640c23a62f3a-a6f668b35f7mr185814266b.31.1718376898096; Fri, 14 Jun 2024 07:54:58 -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> <20240614144248.GA20136@pendragon.ideasonboard.com> In-Reply-To: <20240614144248.GA20136@pendragon.ideasonboard.com> From: Julien Stephan Date: Fri, 14 Jun 2024 16:54:47 +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 16:43, Laurent Pinchart a =C3=A9crit : > > Hi Julien, > > On Fri, Jun 14, 2024 at 04:14:52PM +0200, Julien Stephan wrote: > > 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= =A9crit : > > > > > > > > > > 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 senso= rs will 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 ma= y be covered > > > > > by streaming start anyway, as a change should be calling stop->st= art anyway). > > > > > > > > > > And for the how is it exposed to the user - well, depends what yo= u mean 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 connect= ed > > > > 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 frequenc= y > > > 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 real= ly > > > 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 ? > According to the datasheet, SENINF_TG1_SEN_CK[21:16] :CLKCNT : Sensor master clock will be ISP_clock/(CLKCNT+1) where CLKCNT >=3D 1 > > > > > /* multiplier is usually bits per pixel, divider is usually num o= f lanes */ > > > > > link_frequency =3D v4l2_get_link_freq(cam_subdev->ctrl_handler, m= ultiplier, 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 clo= ck accordingly. > > > > > > > > > > Cheers > > > > > Angelo > > > > > > > > > [...] > > -- > Regards, > > Laurent Pinchart