From patchwork Mon Sep 2 15:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 824798 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 555FB19C56C; Mon, 2 Sep 2024 15:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292658; cv=none; b=II1GMyDQarXAyXylxk4ILRitzE1SsqMDSwH9bkXVAto7ycQOkzzvwn742mXHjjPQHSaI4tMVyiw40nEL7+sv5CzAibMf9n4KVK5CwdxXMZ+CYj/zDf43C8JPUFHtXLr/phWqjrV2aLMJdypsTx7bifaS9rAT4yxjzMG0wdXfhIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292658; c=relaxed/simple; bh=TjTzZ6RkcIen3xbkPeqen6B14I4PyzrsLM9e/EvlDLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Mg+ovn+XQJykCVNxzgREuFGpiYxj4/R2qUPnVjrSGNaIbsZju3ERon7fIgPk8KB2cC8Jo2mhhTVl+fL3lQKkY/zux8GYHLcchCXrTHfb6BWRSid4cHyI+GK6c7XFGI10CB6SPRF9IcyDnUj0GZ3EBCPnVYJmgVMFJBzqhfcGLbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YXWkPO18; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YXWkPO18" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5c26b5f1ea6so121446a12.0; Mon, 02 Sep 2024 08:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292655; x=1725897455; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=g4xtMGXLEzp83kpWPxfV24dy9j1c1Bq2RgsAdYrXBIg=; b=YXWkPO18du5gAv1G2r9Cr2rbrrqKOHcnXdDzm6fW/vH2sQaO//SkTbNzmTMRKlDeiE WFu/iMZdDNZuej4zKUu163MsJzU73bA1mVsefEVTZCFs9CBRMB/97C9Izqa4q5OWx4RT K+2E+IEMM59/5fqMzd1VcfgLiLeqi+TNvBix2Eri7bmLpbE6iB+qYpPsROLeWKLyGVYD QoKSF1pvjxmskOGPnpDnB9gBxPJgsEFXj9/XzOcxncy/F9rebSgdvhU58OZite2PnU7A dds01BkoilC1x+KvrZBsaMhQjNw837JOIAf+ef7I4D86CxuCqSZpXGteaww1ShqT4Bha Sngw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292655; x=1725897455; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g4xtMGXLEzp83kpWPxfV24dy9j1c1Bq2RgsAdYrXBIg=; b=QUleqrb819S9A7X6AUDxVM1kBV/bZwDd2Om6g2Lm50EQvd6vF86nncis6+p/QHegL1 GcSb3bHS6Xqa1TFUMlXzbqzZW+Lnhvty949Qq+z5wzTj/SbGR6h8clhp5L+lyCf3aFTs Ixrv6RoRTMI6bTScI5W5ONvValvGEd6CcbGoW8DqYjHzwYEqD43vmFl44+gOKwp6PJNc 4tOS0InOd8siWjhUTD/4AoHg7csvPcV26OE8/MnaRXL/quk1/FONbCIJSSkC0Xav+6+l gUb+jcQlMCoY8lPx/b41ACqNSdFzacdqhrmrF+oCM7MoN9W6Ec58y9lbQ5Dtp1UdXYI5 1fnQ== X-Forwarded-Encrypted: i=1; AJvYcCUzVgRcxDJhnUlmb4xXrM1uQf7gpROJqaX1hNxLUPwLt+LGcmMxMvlMsHsxaEC5bbrOtzMUHclzfa+wd5o=@vger.kernel.org, AJvYcCWHGGMm942nEbs/Fx12epa1jeRaer5m+vXBU1PqvSLAY/28S2eIxbDCW2J9xZq3H1VUprr4t60YGRIBv4Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu2WtgsMfLwEG7xeXhdanDPfYFP2vKnuKnyC3q8froGZ4nez81 TZeYRdkfSOYWZFp+NNrp/qWeapb2oo6+Rnyd6oN48vxEq8DSLD/h X-Google-Smtp-Source: AGHT+IEVR5MgwnaBnoGQ5m3oht3U3vai0mM4pGf4q5024sK3Grw7V9SqYdcZtsmDA2KzyPqdMpZxRw== X-Received: by 2002:a17:907:d08:b0:a86:6d39:cbfd with SMTP id a640c23a62f3a-a89fafad393mr351438266b.57.1725292655503; Mon, 02 Sep 2024 08:57:35 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:35 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:26 +0200 Subject: [PATCH v3 1/7] media: i2c: imx290: Define standby mode values Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-1-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara The imx290 datasheet states that the IMX290_STANDBY register has two values: 0 for operating and 1 for standby. Define and use them. Signed-off-by: Benjamin Bara --- Changes since v2: - new, split out from the previous 1/2 --- drivers/media/i2c/imx290.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 4150e6e4b9a6..1c97f9650eb4 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -29,6 +29,8 @@ #include #define IMX290_STANDBY CCI_REG8(0x3000) +#define IMX290_STANDBY_OPERATING 0x00 +#define IMX290_STANDBY_STANDBY BIT(0) #define IMX290_REGHOLD CCI_REG8(0x3001) #define IMX290_XMSTA CCI_REG8(0x3002) #define IMX290_ADBIT CCI_REG8(0x3005) @@ -1016,7 +1018,8 @@ static int imx290_start_streaming(struct imx290 *imx290, return ret; } - cci_write(imx290->regmap, IMX290_STANDBY, 0x00, &ret); + cci_write(imx290->regmap, IMX290_STANDBY, IMX290_STANDBY_OPERATING, + &ret); msleep(30); @@ -1029,7 +1032,7 @@ static int imx290_stop_streaming(struct imx290 *imx290) { int ret = 0; - cci_write(imx290->regmap, IMX290_STANDBY, 0x01, &ret); + cci_write(imx290->regmap, IMX290_STANDBY, IMX290_STANDBY_STANDBY, &ret); msleep(30); From patchwork Mon Sep 2 15:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 825164 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 B11DD1A265C; Mon, 2 Sep 2024 15:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292660; cv=none; b=gQZ9jaX9o/T68m4glMKmAQ4t2giTTBZ/x3xq+XOmbmiAlyuTULISNV/XbCknov4Ir+gqrl0FFNxZ58yV3AFYtuWRPs58b8cEqo7t+BkUtps7pUmOdBdCUmAZ7YrTjMjDV+WaAGVGU4egK91TWO+3RII0L8AC7Mr48pZe02jhYqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292660; c=relaxed/simple; bh=dhIUmqGXD7ukNGJkdpSPw/0b0JTtqY9BJywHGpeznpU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gf1r0LM5mpouYv3J8pvkh19bRPFqIdzYRoeIdhPFwg6Ta9ofhSwYrPxSJNEXsBsrOZJfHVhdxWzXsVPh5v9GrC+jkQkMhMpCl0ETogAVPnrI0k9VgRQGXuJmJadHxPGqP6hWFeMZYHpklJ8KHK0QWnBU4QP0uAWTIuVwlxtz04U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c7n/JLd4; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c7n/JLd4" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5c210e23573so4474444a12.0; Mon, 02 Sep 2024 08:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292657; x=1725897457; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NOTuNT2pG3NdBDrQ4sOowXdydQbe5NJerAYtbOYu3W0=; b=c7n/JLd4NMdkY6BqSJ3hBqF/HOvWxpXHJJoDH8iWEQi4oEbdbGZ7YhMDtJ4ossZO61 ge+ndZ8xaNV9kaGkkOJ1S9Yt3fROhgBhPEutBmjkXtAbg3nsXwdSVlQrgsMjiNn9fY/K tm/Dw7VzlL9ttRjQVNzXKj+34cqzV+tOa9HTpF9d66h5UDbfpaoCR01G0aWD3pkI+PRu vVUUwM6Kjn+GavIDG15ZRkZH+rBy3POBKJeEUdINXzsKIoyyHXiJwPWLEoF7VJ5fsd2t 3eWjLt3+SjZsMHUGXcx5d3UBnV6el/dvFxSXGd/lbhaCF4tKfX+7xJrW9hqW+bCqGaBC Egxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292657; x=1725897457; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NOTuNT2pG3NdBDrQ4sOowXdydQbe5NJerAYtbOYu3W0=; b=Rg0AzFvRA0JSK7Wsml9OotFNLaRR4Q/bgmCkipzdCHd+LRJAMDACCXK4TyL+guFtSX LzJTfJ3ubhkXWtmwKx6HWBgJ6BNwILIhSpWCpAkcGl6tSmG8FZCysE8IqM5sWhxZ5eKt iLi/v1FsCKQtkxCvlO1w8mWF3ndvJ2udGELrMFvRxOkb9fJISmpC4xKXhp875UAYq0Zo jz6b+XOetEb3K6HlcjGYtLF2BNG0ckIteFQcZMv8meQoTZVscerzdwIucrBeVFzgyYsE ULOxDdkWXaAqQaik6UnjfQMVY3f2z7phtzEKGelhi3x3x3bFcT5aK0YosByLOIRhmCK2 V/Zg== X-Forwarded-Encrypted: i=1; AJvYcCVHRAsrOtn6+h5JxUQKBZnEfUR1GmUauc/v69A2zJS3QaWT97M3zaAGygYjewATTOyXa9wBbO6o5zmhRrI=@vger.kernel.org, AJvYcCXYzGTktXo5Mo1Vmjh0x2yo/zI8ddUSpCqVhRmXO2qC/dFX3X/eZxlJSTGTbpxMUZJoFtFQ3IR+wTmS0J0=@vger.kernel.org X-Gm-Message-State: AOJu0YzaZTbMJ7/ZjTxHmHKaOhVmpjtYycBmFHr6qWxu6q3v6/gouV09 kZIDR0g1I98wstGtlTqauhafcz+T8ZuN6c44Wp9/+k/cws3YtLhf X-Google-Smtp-Source: AGHT+IEoQIfVVefmqqaw6Je2s5pdfIvCaNfR+B8X8Ji2/2FJOsHtov518enxdZa31uYoylPz1sJnGw== X-Received: by 2002:a17:907:971c:b0:a86:6e5e:620d with SMTP id a640c23a62f3a-a8a1d2d5cc5mr50133066b.27.1725292656793; Mon, 02 Sep 2024 08:57:36 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:35 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:27 +0200 Subject: [PATCH v3 2/7] media: i2c: imx290: Define absolute control ranges Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-2-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara For now, the driver activates the first mode (1080p) as current active mode in probe(). This e.g. means that one cannot set VBLANK below 45 (vmax_min - height), although theoretically the minimum is 30 (720p mode). Define the absolute possible/supported ranges to have them available later. Signed-off-by: Benjamin Bara --- Changes since v2: - new --- drivers/media/i2c/imx290.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 1c97f9650eb4..466492bab600 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -499,6 +499,10 @@ static const struct imx290_clk_cfg imx290_720p_clock_config[] = { }; /* Mode configs */ +#define WIDTH_720P 1280 +#define HEIGHT_720P 720 +#define MINIMUM_WIDTH WIDTH_720P +#define MINIMUM_HEIGHT HEIGHT_720P static const struct imx290_mode imx290_modes_2lanes[] = { { .width = 1920, @@ -512,8 +516,8 @@ static const struct imx290_mode imx290_modes_2lanes[] = { .clk_cfg = imx290_1080p_clock_config, }, { - .width = 1280, - .height = 720, + .width = WIDTH_720P, + .height = HEIGHT_720P, .hmax_min = 3300, .vmax_min = 750, .link_freq_index = FREQ_INDEX_720P, @@ -537,8 +541,8 @@ static const struct imx290_mode imx290_modes_4lanes[] = { .clk_cfg = imx290_1080p_clock_config, }, { - .width = 1280, - .height = 720, + .width = WIDTH_720P, + .height = HEIGHT_720P, .hmax_min = 3300, .vmax_min = 750, .link_freq_index = FREQ_INDEX_720P, @@ -846,6 +850,30 @@ static const char * const imx290_test_pattern_menu[] = { "000/555h Toggle Pattern", }; +/* absolute supported control ranges */ +#define HBLANK_MAX (IMX290_HMAX_MAX - MINIMUM_WIDTH) +#define VBLANK_MAX (IMX290_VMAX_MAX - MINIMUM_HEIGHT) +static unsigned int imx290_get_blank_min(const struct imx290 *imx290, bool v) +{ + const struct imx290_mode *modes = imx290_modes_ptr(imx290); + unsigned int min = UINT_MAX; + int i; + + for (i = 0; i < imx290_modes_num(imx290); i++) { + unsigned int tmp; + + if (v) + tmp = modes[i].hmax_min - modes[i].width; + else + tmp = modes[i].vmax_min - modes[i].height; + + if (tmp < min) + min = tmp; + } + + return min; +} + static void imx290_ctrl_update(struct imx290 *imx290, const struct imx290_mode *mode) { From patchwork Mon Sep 2 15:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 824797 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 112561A3029; Mon, 2 Sep 2024 15:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292660; cv=none; b=HhP2tiUfQp75a9gj7DLPYhOLvw58Fcc7Oqu2FDJY26AvgJXJuuaOHd+6aCXRxxzHmEMDFeunhFh7ATLmid3qEvMvcalZe4rY2ftwBZfh+hbMxSKPDEDyzDOGLy4s5mK0ENRzHDUzoWI+zWygmEgSUCKXCZnjXpqXP2qomFqnuQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292660; c=relaxed/simple; bh=2Y1CK/ZUdRcqXt3dmTgNqjmsP7DbbBhP6WuYBevo8jk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S3Xw7n1ulWH6z8Y6DWfKqy5JlW1+v2B0+FdkWx1bUr5BYWpL2qdYrynZaL0Mp0hkZPOVt7jP9WEjuC3UnWmWU+yFVwoaUYrDKVU8h3QiJig/JUomuSWwVw1CO+L1TklscjQaugfv4Hswtz2rvRUM8xxWTbO4QWANI/ZjH8X9epg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QA59RIqc; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QA59RIqc" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a867a564911so529316566b.2; Mon, 02 Sep 2024 08:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292657; x=1725897457; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NXwHXEw95cMboYJFBjnBrAHhlVpCookFbgIsrq6R6Z4=; b=QA59RIqcSkAs26B54PxiAV+x6HYvASfIscKkq+TI0BT4Pxxo/tbVpPwWLkhOiTsFM8 ZDiL2dWL5p0U2TLumEHiUih7ZWN0tsBFY8t9xtnuWh402sOMQFhK+T4AssRozKKv/dOG T22HB+CF/Khln/bQ0CfYB9hMUjuyBDcpFoGs9xpslWU1E5aSq8E19x7tcloNYvsVecJa dIi8ErJePpeDl1xC4YgJzeOkn+cUIJ6auaGNkfZImmr//sVchc2+g6VznCqPp7qgR/cp c3t6iZD26DkZsODo3fP5jU73EOXz9CNCa2xBvrXd3bB+3OX9iKfilpHs4y7WksberzGu Yo4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292657; x=1725897457; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NXwHXEw95cMboYJFBjnBrAHhlVpCookFbgIsrq6R6Z4=; b=ahWHp1nJYTrMCM86cTkINMTwsFytilvJgPzsywHpkZnorN2NUtjsU2HDxC3g4C8fOK /Wy5GGwv3Edz5PJbsvqSJE3jrBZwZljC+LIMvczgMoow2evnz8j+9+osi/IbXNXzmffX V/kLpTGP1Lcm1oMb/Ia2hLTEpm8Gx9/j7JaipnnV0Bx3mVaRQx6KxE/1C1VIztVowP2U c0lrUm46xQPZkC7Yjs64FKr6c8JL2JdW4z1eQUL5jR+vksFMR1s+0c6ZM2p6/uI03wNg M1vqt1TtWYn9NsKs+/xdu8L9RBTVCYPtx/MjO6Qy0mmqOJ0Ux2EYsY6vBzo8oAVsv+lT Z45Q== X-Forwarded-Encrypted: i=1; AJvYcCVnVzku48SRvc6MICj4xj/7NlaaTtugq02nZhtJrvWdd8WvandQZlzLOlcPUFCEHVZWqGhGMpVc1xEV2k8=@vger.kernel.org, AJvYcCXf1dTg8p4+/6EKEwSUnUVE2rKULGUk1HKuOeB4Cq66ICicGoo76jzHV5k2qES3Zh1wU2T3z5Y/Lj4+crs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2f6nUcuM8IdnHlq+7XYzTv+y8l/p4WoU1Mw0OilpKfrnCyMJD ImJTJMrEqzTizh/+wB5zC3LnODLGp+JyeCPz5lx/xfflhvaBg3ST X-Google-Smtp-Source: AGHT+IEMD83ccy+oSFeK9kl7eDfBn5hiI7P5VcdM1rqK0OivirKXoCNu9QzZ7dV6iRf6BU7mHdYslw== X-Received: by 2002:a17:907:7f24:b0:a86:9690:9c10 with SMTP id a640c23a62f3a-a89b96f8b6emr676816666b.49.1725292657312; Mon, 02 Sep 2024 08:57:37 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:37 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:28 +0200 Subject: [PATCH v3 3/7] media: i2c: imx290: Remove CHIP_ID reg definition Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-3-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara This register is not described in the public available imx290 datasheet. Additionally, a read returns '0x07d0' for an imx327lqr and also for an imx462, which means it cannot be used to distinguish between those two imx290 derivatives. Reviewed-by: Laurent Pinchart Signed-off-by: Benjamin Bara --- Changes since v2: - picked up R-b of Laurent (thx!) --- drivers/media/i2c/imx290.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 466492bab600..6812e7cb9e23 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -80,7 +80,6 @@ #define IMX290_ADBIT2 CCI_REG8(0x317c) #define IMX290_ADBIT2_10BIT 0x12 #define IMX290_ADBIT2_12BIT 0x00 -#define IMX290_CHIP_ID CCI_REG16_LE(0x319a) #define IMX290_ADBIT3 CCI_REG8(0x31ec) #define IMX290_ADBIT3_10BIT 0x37 #define IMX290_ADBIT3_12BIT 0x0e From patchwork Mon Sep 2 15:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 824796 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.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 58B361A3050; Mon, 2 Sep 2024 15:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292662; cv=none; b=PmzDxrYp88jIKj8q9ZB8KjqSF2tSnH2enu9EmzIJI8T7fL9EtgbRtqpzmlVyGXqTv0pY+UtdGv0HBKPIA/1RVcTfIe8FIC5ynE3+Rb8Wbwfbtzz0G2OSew0HkdkYF4TY77e/HiC9CG6k6u+lbho8lOvR1ReTH4OCnrDPEgzaLng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292662; c=relaxed/simple; bh=/qpG/2Z5WXZGm8WmkwLs3toa6eHEzRVbA+bjWc2mt+k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MNYjamUzflWTh7drak3/3kd4xYGQV8VBuHJzYeaJ45FwLrewj7OyX347q6UFo1D+2ui+NzHIGj7VR6tLvTsxRg4bnHMFhDzzgrYIxeHe1qq+KLk6U0ghYY5UHDruAGFuDjayFzK7Vil6rAfpwpVdwGXtrJ9HUbA30c4JO72WM/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gWcpg/8n; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gWcpg/8n" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5353cd18c20so5210808e87.0; Mon, 02 Sep 2024 08:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292658; x=1725897458; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gySomjgMUV/LhUrr958ADeJEzee1tSZcTuNwCSieT4k=; b=gWcpg/8nKNxerrb3oQsxDxAf7n0G/JTLkaENht8HtPx4WCLX3Ugb2rmvP+er/zAy30 DyFq7FIualLqf/DtcLjICOj5xcj8RMWJ/oIW6Fi0H8s1Sly1N76JTk7udWp4+0xiP5Er fOSdO/TgLLvcsImDyLZI7lO59bxmFxyo9LjUc1pLqSXsFCR67ysm4eE020bf6wofWSVq 0PDD12dr5D3HR5YeTNdK3+rWKRot35K8SmwEY1qloFEE3SSUVd65/B4YyjpST0W8mDus ezLJv9FYqS6gqkkAA23vxtGFmFRf93ADaHus4uOoJIUnQmW1SYzOZExLn5Lp5UD2sMPl HJHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292658; x=1725897458; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gySomjgMUV/LhUrr958ADeJEzee1tSZcTuNwCSieT4k=; b=LK4qpUQx7Wi3RGTzTzVgvLh2FAtVvn9VlOQSf/5ZC0kKNf3HLJOyxfjF1Vu51s2vvi VtdmonHn9HCrzvdBS1PXTmctSK2nk/D6xlPTHjh3tgcsLD5XKd6sCe66CodSmkwfaoO+ mutcSWFub7Ib1+CfxJFvRwRSgW8bSa65lpUV6C8+hRkZA0WW5o7Ap7WI81D6SFlH6Yej l9JX3Hi6q+X2+HrBCf+S+EagywFzvsYpCr+86UgSHpILdjCYy9MzPI9Igq3jlr700sm7 Yg5qcuDnwOrZv6+qwLkBjXykhCkcI+Cd8Sx2Rc/gRR69e3837JbeTtqnIS48P7olPaq1 GTig== X-Forwarded-Encrypted: i=1; AJvYcCUS7J32h4AMPvQACDbzzXKcUngvWI/G3FSeIzLDyJY/Tp5vOn/zASNIqJCDo1nTwmZo2EokZtQy4wJhU8M=@vger.kernel.org, AJvYcCUdHnRmi1kqqD19KvRCanRdfEwsHabOX4qDMXWewjQ0nlw/xCuSzdrYGNZXaq5am1raEP2fpIdIWSNB9N8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywst6ilVzyOCpuQWFQa2w+Ufn9R//keEfxoyDv80PyGF4PYLW2q 43r0AnhVgd8emUYEGxMiSLyyCR6IxgJLUIWWmWquQKQR0x4Y5sREqQEbC7QJ X-Google-Smtp-Source: AGHT+IECCIS7n0qtjSCOMA/WBAr1wEWl2cuJHHAZgShmBdFOgCsT+SftyNWty8H8C5g81ZcvfXGGVw== X-Received: by 2002:a05:6512:124b:b0:530:ba92:f9a5 with SMTP id 2adb3069b0e04-53546b905d6mr7540905e87.45.1725292657808; Mon, 02 Sep 2024 08:57:37 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:37 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:29 +0200 Subject: [PATCH v3 4/7] media: i2c: imx290: Introduce initial "off" mode & link freq Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-4-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara To be compliant to the V4L2 API, the driver currently "randomly" decides on one of the two supported modes which also implies a link frequency. Add a new mode and frequency which symbolize that the sensor is not in use. This can be used as a default value during probe() and enables us to avoid communication with the sensor. Signed-off-by: Benjamin Bara --- Changes since v2: - new --- drivers/media/i2c/imx290.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 6812e7cb9e23..ece4d66001f5 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -425,14 +425,17 @@ static const struct imx290_csi_cfg imx290_csi_297mhz = { /* supported link frequencies */ #define FREQ_INDEX_1080P 0 #define FREQ_INDEX_720P 1 +#define FREQ_INDEX_OFF 2 static const s64 imx290_link_freq_2lanes[] = { [FREQ_INDEX_1080P] = 445500000, [FREQ_INDEX_720P] = 297000000, + [FREQ_INDEX_OFF] = 0, }; static const s64 imx290_link_freq_4lanes[] = { [FREQ_INDEX_1080P] = 222750000, [FREQ_INDEX_720P] = 148500000, + [FREQ_INDEX_OFF] = 0, }; /* @@ -552,6 +555,10 @@ static const struct imx290_mode imx290_modes_4lanes[] = { }, }; +static const struct imx290_mode imx290_mode_off = { + .link_freq_index = FREQ_INDEX_OFF, +}; + static inline const struct imx290_mode *imx290_modes_ptr(const struct imx290 *imx290) { if (imx290->nlanes == 2) @@ -876,10 +883,19 @@ static unsigned int imx290_get_blank_min(const struct imx290 *imx290, bool v) static void imx290_ctrl_update(struct imx290 *imx290, const struct imx290_mode *mode) { - unsigned int hblank_min = mode->hmax_min - mode->width; - unsigned int hblank_max = IMX290_HMAX_MAX - mode->width; - unsigned int vblank_min = mode->vmax_min - mode->height; - unsigned int vblank_max = IMX290_VMAX_MAX - mode->height; + unsigned int hblank_min, hblank_max, vblank_min, vblank_max; + + if (mode == &imx290_mode_off) { + hblank_min = imx290_get_blank_min(imx290, false); + hblank_max = HBLANK_MAX; + vblank_min = imx290_get_blank_min(imx290, true); + vblank_max = VBLANK_MAX; + } else { + hblank_min = mode->hmax_min - mode->width; + hblank_max = IMX290_HMAX_MAX - mode->width; + vblank_min = mode->vmax_min - mode->height; + vblank_max = IMX290_VMAX_MAX - mode->height; + } __v4l2_ctrl_s_ctrl(imx290->link_freq, mode->link_freq_index); @@ -932,7 +948,8 @@ static int imx290_ctrl_init(struct imx290 *imx290) imx290->link_freq = v4l2_ctrl_new_int_menu(&imx290->ctrls, &imx290_ctrl_ops, V4L2_CID_LINK_FREQ, - imx290_link_freqs_num(imx290) - 1, 0, + imx290_link_freqs_num(imx290) - 1, + FREQ_INDEX_OFF, imx290_link_freqs_ptr(imx290)); if (imx290->link_freq) imx290->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; @@ -1278,7 +1295,7 @@ static int imx290_subdev_init(struct imx290 *imx290) struct v4l2_subdev_state *state; int ret; - imx290->current_mode = &imx290_modes_ptr(imx290)[0]; + imx290->current_mode = &imx290_mode_off; v4l2_i2c_subdev_init(&imx290->sd, client, &imx290_subdev_ops); imx290->sd.internal_ops = &imx290_internal_ops; From patchwork Mon Sep 2 15:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 825163 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 62DAD1A3053; Mon, 2 Sep 2024 15:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292662; cv=none; b=PxXhdyyUow2ZTyuL6IsgicwiUX/SuN0iJ9Zo9y2+SJvRQ2n6lBjUqV0aYcXNNqR4qUfFAWmvL76flKqBWDbS5VS5p5v84fKlQ3o+kRLar2LvE6Xn7onWZTF1GvU4yNh7a/DzrUUo2gg8ih4/TA0YcUvsekihUOZGdlFjrEqckKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292662; c=relaxed/simple; bh=545SzH11XYDnTThOv4+RccI0gK/V1QB8eBYGK3TtJew=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=exQQqlsbgiWBCE0ZK0KADJ5fxbCZ694wGFXHzsPIndc3EHfjTCQjmArv703AXzvK2Z876DdAHjj+aPyyqp5rgNoNeIG0quMZzuQzaPDLHhbVY4JpQ5kORqZBAsKhF8t2Ad/WPbLbHtuvRaFIWfHqgHVySxOSnyg05VqB+qJLkAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ia+Onzaf; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ia+Onzaf" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a869332c2c2so857335666b.0; Mon, 02 Sep 2024 08:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292659; x=1725897459; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=w4oT7d5JXUFK7x6k61bLujQ6czdYd/ZPn3pkZyd7gi4=; b=ia+Onzaf73xMDrAPvMO3ng0FDHPqIg79mUvHtHLdHeQU60bSnJ9GfEZdBXi/Rw8RUY S16SHuUtQvXDNPB9inoAfhW17C2cUxWcsbyyQVyfvDExgVXUTBZ3M4GV8X2n/D67AM5z 5DL88vWG1yPVf11irnQN70QcXaHO2yR7cWcJ1Xt4W7okRzz52f/0SUnC7HgwTRHca1JF NMXujxkxkWrBrR41pUTkKPEjZsEMn7FK8c5nwqwvgc4dAyno3sWmlBiu0pHPX22nPfqL 6Ql5oMYpiM3BdvHRiAHovw0Sb/lYCAJ9/VmGl7DTrWxdYnAX2Yy/IoBp5P4KcyL/glYv GWmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292659; x=1725897459; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w4oT7d5JXUFK7x6k61bLujQ6czdYd/ZPn3pkZyd7gi4=; b=SDyGCxAuVfBbydChwLZCc4M7ZH5YBzWfvHsVcYSQuE0gPHwqJa5+lsk6plHzlPNq4M xUlPh0Al8X4pvvooCg1Yaa541CcLfhTnsgn5n1tL5AGt5ehDQQpLEq6Zbuiql73Tr/hs gDI4s4+QOoxGRWo1cvTY1gg+p8CmLJsQ+UUCoOCPZxgWJ13LpTZtEsA9iN2vvw8+ngCC W3QK+EExU+wzprOVd82TbPm5of6LqeSdFf9rPlcA9NgI0Pd/V98GZ2wo2yqlJCHJqonO 1IDaj3buqNdmh3S2PiEYIy7SA6Eueh84Pxv2IZ4NjoU2Kgv3f8b7jGBVFSF3jZvZNvK4 Z94Q== X-Forwarded-Encrypted: i=1; AJvYcCV9pVJHS4fALeGt5g9uICPP6cMKJ9f9YPl0zNV047kMi9FdRDTu/mZ8Am/QHc2Xf7X3eK0Pl7JEdjVWx3I=@vger.kernel.org, AJvYcCVKzLaCTeqNTWau/fGr1WXBevJykH0KlNwlxG4lUS+vTZU8Rv0WXMvPyuRhdcj8j+ngcj0uEnurUsERWI4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1hbNKy8sS2/0z70F31SwCbGJ6hlOHxIwOZRsu9+G3u+8cRxg3 RTzMpnFaPccskfo5Um3Epp53CDUHL+XlYvw+E5gEfyCsUPZIF17z X-Google-Smtp-Source: AGHT+IG8+G+ISoXqqXfk53k8g5fxRXUlI2gKzbNonBvSChRGgrPyHad6P03xGhRAItpXgVL+q3y7RQ== X-Received: by 2002:a17:907:6d11:b0:a86:9ff9:6768 with SMTP id a640c23a62f3a-a89827a401bmr1510643266b.22.1725292658598; Mon, 02 Sep 2024 08:57:38 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:38 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:30 +0200 Subject: [PATCH v3 5/7] media: i2c: imx290: Avoid communication during probe() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-5-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara As we don't know the mode during probe(), it doesn't make sense to update the sensors' registers with assumptions. Avoid the communication in this case. Signed-off-by: Benjamin Bara --- Changes since v2: - new --- drivers/media/i2c/imx290.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index ece4d66001f5..9610e9fd2059 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -769,6 +769,10 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl) if (!pm_runtime_get_if_in_use(imx290->dev)) return 0; + /* V4L2 controls values will be applied only when mode is known */ + if (imx290->current_mode == &imx290_mode_off) + return 0; + state = v4l2_subdev_get_locked_active_state(&imx290->sd); format = v4l2_subdev_state_get_format(state, 0); From patchwork Mon Sep 2 15:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 825162 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.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 F0AEB1AB6F2; Mon, 2 Sep 2024 15:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292663; cv=none; b=BPOyTmxiqLBVQcpGTBP6pBiLISb5AZcZ+Oocrlw0Qkk3kNkGloVwdMY6ywRpFEUKS+eHw40/FqBohOnsMOn87I3Jm+MCc3EYfFEOiS7vWDSGguqRYNxE7vGtdL0G5waCQ7KRXbdQfioBqatwRDbefh+INGPPeb4iH3AbUK+W9z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292663; c=relaxed/simple; bh=ElOxBofJFS3FqIivMvaZANT2xPW9ATldUSTSCIy5YXU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lVicrHd8uc1+QQRsDubQ7PujUSlWB/RzR60ClKB+JXgkoSxIcX+P53tk4c+caPC68n8U103WZkHMQ5UNUHtlAe9xE5wuh8dSVlZo5wD8Gl7lAnFltAUs6ZX81ZcY9MB5JjvJdlsXAIg8j53EIvaHXRZL6T3nSkNCIpCGGi5WEAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ikyftJkn; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ikyftJkn" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a86c476f679so515039566b.1; Mon, 02 Sep 2024 08:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292659; x=1725897459; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=UH91BWlbNf9k3CqoGaHxhWlCV3pTOvd9OXWFBubCGPg=; b=ikyftJknGRxyhzWZEc65cAFncQDEJuRPJ3BMKO4AunJE20C9L/EXbkTVpn3JaI3GNN iUc22x1Peeq+O4nAyOOA1LB6erz0DwtN4PiVRKiIgBX4ixnptNTmBdrhWl2m3fiOCtLJ 8HdUhJRg4dYUzq86dl57/e4UYzWR6Ocw/8GBzEwljK2eCkWR5ewd7ZrRtHDfyw8U+ha/ jMRNmXxoCmmEfBwbb4hH6L2kOxzi0WWqvkbPOnFTfUnmFs3E+nWUOv+ASotoDrrFKU4H sE65/4REP5DTI5LbWC3/N/E/O0Euj2PpuGyYykLfxL6OP6cO2n1wRC1VTJdV6kooj/Zq nPpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292659; x=1725897459; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UH91BWlbNf9k3CqoGaHxhWlCV3pTOvd9OXWFBubCGPg=; b=lVlTlz5SxMf8Zo4rgV5hTJs/wxhOGcfB4U5sKvdEpO3Kx5lDZCjzTM5zYfqLwxmipB IXhAtEnGBKnXkRPEtKvNT2LMnenCQV4gBG41Uf1TWKUok2Q0gsjl5pnIwli5JNdhgU8F t1i2edb5+yJujW1P+EazEe20GlPg6HMDJW9l253OLrVHP5EZxDgyi9TglDriTYQUsQ1g zjFcAIAMddtIVYUA6SZdnekJp0tgPTlHor3duj68lmHYX/nAD4VpwF1njtA8u2jzxD2Z CTRA4cbR5IBDBys4i1puAeXyJr/HToiKuoCkLfIcOf2c4a1eQwMF7MArrMt3qdJ0U3wq osVw== X-Forwarded-Encrypted: i=1; AJvYcCVutaQScsKZTR4+LvqP+8BMxjDLYMpz+6Lnq0kIl6GmcNzMT/1IT07eELArFIq2c0Bx763eGIynEr8h3is=@vger.kernel.org, AJvYcCWUQyx79OnghB/mn5MZgsZwQtJJccNB0ITsCrmem5eOWncvD5smD2DT7enxteFlStW4ViSU+ML1dF5QYeI=@vger.kernel.org X-Gm-Message-State: AOJu0YziTbNovj+YLzneuEnChQesdS0ZUyTNezmpHBKu+9qYibH698Id xgJs0VqGPi7V0EL3OXsNBarJU+hRFpsqygA3k1cGnW3tdfdSnCPS X-Google-Smtp-Source: AGHT+IF/avJyViP33NxlB7JIvafCpQ62Qk7c3tV78whp3DOCwDoGgx03vbyld+NkellYNus7gNflYw== X-Received: by 2002:a17:907:7d8e:b0:a72:6849:cb0f with SMTP id a640c23a62f3a-a89b9729537mr544000366b.62.1725292659125; Mon, 02 Sep 2024 08:57:39 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:38 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:31 +0200 Subject: [PATCH v3 6/7] media: i2c: imx290: Check for availability in probe() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-6-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara Currently, the V4L2 subdevice is also created when the device is not available/connected. From userspace perspective, there is no visible difference between a working and not-working subdevice (except when trying it out). This commit adds a simple availability check before starting with the subdev initialization to error out instead. Signed-off-by: Benjamin Bara --- Changes since v2: - the new 1/8 is split out - use dev_err_probe() (thx Laurent) --- drivers/media/i2c/imx290.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 9610e9fd2059..6b292bbb0856 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -1571,6 +1571,7 @@ static int imx290_probe(struct i2c_client *client) { struct device *dev = &client->dev; struct imx290 *imx290; + u64 val; int ret; imx290 = devm_kzalloc(dev, sizeof(*imx290), GFP_KERNEL); @@ -1631,6 +1632,17 @@ static int imx290_probe(struct i2c_client *client) pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); + /* Make sure the sensor is available before V4L2 subdev init. */ + ret = cci_read(imx290->regmap, IMX290_STANDBY, &val, NULL); + if (ret) { + ret = dev_err_probe(dev, -ENODEV, "Failed to detect sensor\n"); + goto err_pm; + } + if (val != IMX290_STANDBY_STANDBY) { + ret = dev_err_probe(dev, -ENODEV, "Sensor is not in standby\n"); + goto err_pm; + } + /* Initialize the V4L2 subdev. */ ret = imx290_subdev_init(imx290); if (ret) From patchwork Mon Sep 2 15:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 824795 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 E9B0B1AB6F3; Mon, 2 Sep 2024 15:57:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292664; cv=none; b=JBeTS19R5ykUqRbAy2fu9QdUkvatBD4raNlN/PzdE61phMIX+j8O6x6HaXOsZHVnHaUJTEZDm/gRXs47Q11zruXnWMvijCdFNyaEOjeTlCrS4IxLsAk/wGDS2aB5hArudDrt3TG4m/R3knU8ApfF3RBe7pC39Cqm9i3nKRBJdzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725292664; c=relaxed/simple; bh=Lzl+omPBtHR44Z4UzBtKNCzvZ4x/bVYsZ1+ORCVtREQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ixBIOEhmsSmD3XiZwuWmoPNKI2AaCTsQtLalv79biXiXMXaTSvJoqKoQsN7+ol0KLwv9v+dBhfT7P9+UPe1g+Gv05Todb9Jr6TDbGm7uCfv35/xsglLt79k20oM/GDxXvBjqyMYWinEA9Ow3lPYwoPLLU7o0b7ZcXTHHtQhApw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HUG/drAB; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HUG/drAB" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-534366c194fso3988619e87.0; Mon, 02 Sep 2024 08:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725292660; x=1725897460; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Z4hI8+kGIT6wXCqJnZXAvzgNsi+lvmQBwJ5g0y2c0eY=; b=HUG/drABLHc4Gq8BL3lT6Edjk8VqEGq+zu0e0CbPws4qPpwifWqGibF/V53LE4ufuD r77w+EHngdGayxjLw7uz0iIhd5svW1x36CKfskVroKBW1dcnibCqWNQBmRoLx49OwSCl l90bcbDoxbfE340g0lGb6Cr3eQWLzrNVQ3hJI7aaDATjuvJPxvknjDtj0ffmZ4isWcZ1 1ZizCfcFYv8i7bGbcUFkDjAikmqVEMtFzo0U0Ppb2sGxqfqDLI/cT+aYqcMjskSBCvO9 B3gsw7rnkRdKrMZsZpWqrmcbIeeV7BMjj1nE6vRUprvhhlkPbgdGXaGbNGw1q9tLM49a srDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725292660; x=1725897460; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z4hI8+kGIT6wXCqJnZXAvzgNsi+lvmQBwJ5g0y2c0eY=; b=SqBF1T0fPknHTjVQW3prmhEVTsQeP1Vlc8792W7oUcHHt4aRVSFj6OaMauw1hY8Hh3 EEf+G0jRZqh2f3GqHskVlP1RRRMh2Kubogk6MRVGmIJSMrBXD+qVzITY13k7eAmhM4HE AyCO/8bV7B2CeqsgkwfHEnso2HBjKJ3PBHn60j5fEI4yEVZIL1+Y94KYNpX8r8ubmTJm wI7wnwgcMqWi68LzcCivuMledVmeSAEOM0B5/VqY7c6WYcs8SQfX76WbLqCBx5FPMcJU I3vrxlkr0JYndDlNoiePLzmPXdK6x7pXqVc50SIkWRO2inonB5C+q9LtWbeCgrcrHG8a 8+dA== X-Forwarded-Encrypted: i=1; AJvYcCWGMQQssWvPXyTJLen3AxkRUadNCSW/jVB00Jzqpvm8END/IyqGgloCPLyx4mveHx4AwizDo4MINr8Hxg8=@vger.kernel.org, AJvYcCWtnaqyDiiy3LSW3ltYgxXsoD4ZB8a7QQqCSADAS4t7KpDcbv6bN+j16qTQVRMWofM49eEFBlz0kaoXex8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw30js7ZXwXybf2eoN1R0W51TPBpa/GX9uQoOL1Ky5yihXl4va1 /nmdvB3KMw/rRJ1POUs/i46JcR9l0Yt/qRW1XEu8O3BsmPQV4Nhq X-Google-Smtp-Source: AGHT+IHq8nsQgQhjegoUPQJBRWJ413Ys61mHnHpnkGz58ELOfcaiYF8SrvSeNxqmCmZHqIHx6w4DtA== X-Received: by 2002:a05:6512:ea7:b0:533:44d7:c055 with SMTP id 2adb3069b0e04-53546b19184mr6908419e87.5.1725292659664; Mon, 02 Sep 2024 08:57:39 -0700 (PDT) Received: from [127.0.1.1] ([2001:67c:2330:2002:af84:a410:1c4f:f793]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6f87sm570951366b.158.2024.09.02.08.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 08:57:39 -0700 (PDT) From: bbara93@gmail.com Date: Mon, 02 Sep 2024 17:57:32 +0200 Subject: [PATCH v3 7/7] media: i2c: imx290: Implement a "privacy mode" for probe() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240902-imx290-avail-v3-7-b32a12799fed@skidata.com> References: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> In-Reply-To: <20240902-imx290-avail-v3-0-b32a12799fed@skidata.com> To: Mauro Carvalho Chehab , Manivannan Sadhasivam , Sakari Ailus Cc: Hans de Goede , Laurent Pinchart , Alexander Stein , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.14.1 From: Benjamin Bara Currently, we have a trade-off between potentially enabling the privacy LED and reading out the connection state of the sensor during probe(). To have a somewhat defined policy for now, make a decision based on the power supplies of the sensor. If they are enabled anyways, communicate with the powered sensor for an availability check. Otherwise, create the subdevice without knowing whether the sensor is connected or not. Signed-off-by: Benjamin Bara --- Changes since v2: - new --- drivers/media/i2c/imx290.c | 82 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 6b292bbb0856..338b2c5ea547 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -1354,6 +1354,17 @@ static void imx290_subdev_cleanup(struct imx290 *imx290) * Power management */ +static bool is_imx290_power_on(struct imx290 *imx) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(imx->supplies); i++) + if (!regulator_is_enabled(imx->supplies[i].consumer)) + return false; + + return true; +} + static int imx290_power_on(struct imx290 *imx290) { int ret; @@ -1571,6 +1582,7 @@ static int imx290_probe(struct i2c_client *client) { struct device *dev = &client->dev; struct imx290 *imx290; + bool power_on; u64 val; int ret; @@ -1611,36 +1623,54 @@ static int imx290_probe(struct i2c_client *client) return ret; /* - * Enable power management. The driver supports runtime PM, but needs to - * work when runtime PM is disabled in the kernel. To that end, power - * the sensor on manually here. + * Privacy mode: if the regulators are not enabled, avoid enabling them. + * In case the regulators are enabled, we still want to make sure that + * the regulators know that they have another consumer, therefore run + * the powering sequence. */ - ret = imx290_power_on(imx290); - if (ret < 0) { - dev_err(dev, "Could not power on the device\n"); - return ret; + power_on = is_imx290_power_on(imx290); + dev_dbg(dev, "%s: power on: %d\n", __func__, power_on); + if (power_on) { + /* + * Enable power management. The driver supports runtime PM, but + * needs to work when runtime PM is disabled in the kernel. To + * that end, power the sensor on manually here. + */ + ret = imx290_power_on(imx290); + if (ret < 0) { + dev_err(dev, "Could not power on the device\n"); + return ret; + } + + /* + * Enable runtime PM with autosuspend. As the device has been + * powered manually, mark it as active, and increase the usage + * count without resuming the device. + */ + pm_runtime_set_active(dev); + pm_runtime_get_noresume(dev); } - /* - * Enable runtime PM with autosuspend. As the device has been powered - * manually, mark it as active, and increase the usage count without - * resuming the device. - */ - pm_runtime_set_active(dev); - pm_runtime_get_noresume(dev); pm_runtime_enable(dev); pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); - /* Make sure the sensor is available before V4L2 subdev init. */ - ret = cci_read(imx290->regmap, IMX290_STANDBY, &val, NULL); - if (ret) { - ret = dev_err_probe(dev, -ENODEV, "Failed to detect sensor\n"); - goto err_pm; - } - if (val != IMX290_STANDBY_STANDBY) { - ret = dev_err_probe(dev, -ENODEV, "Sensor is not in standby\n"); - goto err_pm; + /* + * Make sure the sensor is available before V4L2 subdev init. + * This only works when the sensor is powered. + */ + if (power_on) { + ret = cci_read(imx290->regmap, IMX290_STANDBY, &val, NULL); + if (ret) { + ret = dev_err_probe(dev, -ENODEV, + "Failed to detect sensor\n"); + goto err_pm; + } + if (val != IMX290_STANDBY_STANDBY) { + ret = dev_err_probe(dev, -ENODEV, + "Sensor is not in standby\n"); + goto err_pm; + } } /* Initialize the V4L2 subdev. */ @@ -1666,8 +1696,10 @@ static int imx290_probe(struct i2c_client *client) * Decrease the PM usage count. The device will get suspended after the * autosuspend delay, turning the power off. */ - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); + if (power_on) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } return 0;