From patchwork Tue Sep 10 17:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798964 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 D8DFD1922E3; Tue, 10 Sep 2024 17:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987981; cv=none; b=cwiG6LODcXHUAwquWetmokeccIIImNKP8p4w1Fglg0pLNvx31mqh6EqlxOkeegfdG/cUuD7TR2OgLW8YD8Ptv1/c+Tv0SSzeUPE+T0Wf1R/th3ybaImrSvyQayhKEcwL6fpaohhh/ejAKEjmikl+yL7/pt12IOm/FaUIzf0d/bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987981; c=relaxed/simple; bh=aY/aJQpV38qNROExL3xJqYKRw9fwpPUOQxSrGJ5yIiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Je/FtU1oYPYVyLOVfqGUvN/T2w8s9WcHmYBjl4Da1P3w1mF2lJgEP8J9aQAojY82yMCxIALo+JJSj7xUUxJnDPFVLbqjm0/+sWcNgoSDqIwIgd9gtPA+RuiiVp1eaxwTZ9U77+7+y6A57PWwPJ5zSfaYQl6UlPG02LL24ZHMPsM= 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=Ew+Ju16R; arc=none smtp.client-ip=209.85.221.53 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="Ew+Ju16R" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-374bfc395a5so17203f8f.0; Tue, 10 Sep 2024 10:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987978; x=1726592778; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Jc7MVYbBTomhAghG+qJoHxAlGvl31VLQMoetsad1iTQ=; b=Ew+Ju16Rww2coDa1KTz4nSnQ2YPnhJFm2AeldzViBtOu57yNBagwJX9UW9aeTnZyLt zxzV/EeKnVbxL/FY49aAGu3nqpk0leSGmscsXRwsbiFhIcNHQCmjqZ1f3F+AMvYIqByW cp5HcR1j09ty8xq1sy3BQIgQBQPXFFIFxJw5fHK4DTqtMvMAwbUCWfZwDugUPY+NbN1K PwFqOhr/X33LqbDCuwbbPXdjNSjEjrj5am0NmXzmocK/Zf0WzEFLOF5d/LapdnCzLI/0 SFZiD/7Mx3t8R3P/DhMPGeMLTGKFfIJ9klxi1cKxiLDrP3Bq2eFd2x/3XCT4+kbFrtmg Smhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987978; x=1726592778; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jc7MVYbBTomhAghG+qJoHxAlGvl31VLQMoetsad1iTQ=; b=d2y6D+QyF69PEwtB/XvsB43ULF9wE9L9FWoza4yl+NETCcNrirtmku+eSta4UPXGID 9CFP1ddDrgZTl/D1SZQVep88UE6xhnsue7wumx3jvsNL5B5o63W22yv/glFfekSUVe1Z Kju/g8vqCXD1q1QSDU770EFDPu3Olv05ZWOEXoj1G6wI/FFyBeGDzOyYHvw9PMXufriZ J+tWmvEA36S9zyHfHEfwaz7I9Oc1vGPkG+jsXA+kmRr13jSwPAq0ZA2PWVmnoEaOGiAa U/oyxoTXI0Dm7uEd2fmkDtlKSUEUrWbZ7JJhHxZEcoqSCgQrHAAnniWzDKcOxUbySben Lqlg== X-Forwarded-Encrypted: i=1; AJvYcCUMquM5MW60Z1nikoTioEILyaCIvWUSLWmrjof2euhr7Ka47/FgPa0VNNjaZGpX78hDbGFH9sIdc/NFgNI=@vger.kernel.org, AJvYcCVbXtE+AByvORotSqpUgn0tcrRQsY/TcD5mAhFPj60uMPt89w2qgxr3JuqcgOlg0+LXU5B+pt8n6GjOCNjeK9R1v9o=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1FLOPGhDFhR+hTmGaW1uEviY/eCZsGSv8+VkXRXxlPDacRVQr CMHgGK7IJAempHSLIcHA/0spzeZ6Md5KpTpl2+UZmojoYM4B5671 X-Google-Smtp-Source: AGHT+IGdEs37CqFnTH/L3fiaagnY/yzdCuig7ywcrD7kKLYsNFPo9lnDw9DrB84U1oqO3LR+fgjqgA== X-Received: by 2002:a5d:5f87:0:b0:374:c400:8556 with SMTP id ffacd0b85a97d-378a8a1b6a6mr3012695f8f.11.1725987977697; Tue, 10 Sep 2024 10:06:17 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:17 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 01/11] media: i2c: ov5645: Add V4L2_SUBDEV_FL_HAS_EVENTS and subscribe hooks Date: Tue, 10 Sep 2024 18:06:00 +0100 Message-Id: <20240910170610.226189-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The OV5645 sensor exposes controls, so the V4L2_SUBDEV_FL_HAS_EVENTS flag should be set and implement subscribe_event and unsubscribe_event hooks. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 019979f553b1..6eedd0310b02 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1042,7 +1043,13 @@ static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { .get_selection = ov5645_get_selection, }; +static const struct v4l2_subdev_core_ops ov5645_core_ops = { + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, +}; + static const struct v4l2_subdev_ops ov5645_subdev_ops = { + .core = &ov5645_core_ops, .video = &ov5645_video_ops, .pad = &ov5645_subdev_pad_ops, }; @@ -1178,7 +1185,7 @@ static int ov5645_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&ov5645->sd, client, &ov5645_subdev_ops); ov5645->sd.internal_ops = &ov5645_internal_ops; - ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; ov5645->pad.flags = MEDIA_PAD_FL_SOURCE; ov5645->sd.dev = &client->dev; ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; From patchwork Tue Sep 10 17:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798965 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 EEF8719B3D8; Tue, 10 Sep 2024 17:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987982; cv=none; b=BJq7sTHhqdUg2bEOg9Oe39Mg8dG3HaZNqIdx0Fm2J93kQNsxkljL/3mbOSgimaTFSBJZwhyn4DsZZ9Hg16IxFc4q/FB9nqQ3GZmJX6mWMMRDa2CK819tLnLCMSgf4Y3jitJg4p5taBhDleR3TYtcMM7zb0anzEFGhskK8Ykt2ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987982; c=relaxed/simple; bh=JGdJLaovjJBbYCO4/ZAujBbI9fa+eu1eoBgflmmamM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qRWpXJN4NAZm68pcMkmeHpeAn4Fwo0YMZhFTjTA+19WmujyXQMdx9+eK1+omNe4eghflhz8r7zpQHs7S/sgMncGWafee7lf/OMDI5yJQbd+69MdDHB8lqcYtwDB6rHVa5ex7VfSmi9UAej3FQ3e1hnwztJTFb/4gNIchAfQfwXs= 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=YgJCUBc8; arc=none smtp.client-ip=209.85.128.45 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="YgJCUBc8" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42cbface8d6so13466505e9.3; Tue, 10 Sep 2024 10:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987979; x=1726592779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EKDEYlUyX9mtDWuZXG8A6gqXn9QYzoYPNiuiR8K1vRg=; b=YgJCUBc8RJ3QHYwA0RbAvZ6Rudfh5jD0zc05sKv5/ppHjIdh5lE8VF+yhuJBJfbdOV FbqJFAH0mYy+0JpKkS/d0QNS2YZc8MAHZ/tV9yVeerFhNUi2XIbjo1n0Ztlvr+/1tpeN 0LUYwDLy7GZl/VlP4k5ZvJq1ZbR3qy7zl6BHk41PMzIF/DRhPRgBDZx5JIwJx6ZqoT8F mJaOYwTzSccNJgv3AdsBVQHklz+fm97le56viOguEUzSIvqIkxuyJNaxuhVLjEqvIcjC Dg4/ek2NXfHWjyV7+mgii2H6C+m0AnVW1DwBNnkCcfV3b1CLiJU9L/tRMoyxXypXR3wC 5/sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987979; x=1726592779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EKDEYlUyX9mtDWuZXG8A6gqXn9QYzoYPNiuiR8K1vRg=; b=wLcYJIe88IulGG9YYHfiI4Ecw+4MyIK6gBAnXiiJDAagB3H1I8a6pYcwICWvzDqAGQ iIkAhhr8gpkn0AoXknPdMpEBJlmOdG+4wEmZVYUox2yuKwIIjHFvd/dmtVBk1xXQLBdh s+GZiqGcLSn1r+cpeguvbm+/2LC3oBVP6XqB0q8HWUVFT/SreYBiMXFlRxJSES+oxrgB 8w1tYQ/xgIl67jV7JtKh+SOEifkPQRcGTL5hEJbLzncqevhOwccYvT6VLtQTX1EhIbXx La25Gu4DzMH4X2IvBbWomGBnkLBuNCp4iQVV8U5Q+jyBVomHI1H8ueBvT6paLPqcy0p4 0f2A== X-Forwarded-Encrypted: i=1; AJvYcCUKSjfW/HZwmDiYk2eS8sGI3RiZz+iazpDrNeAP7nTtOFazyyu4kBL1Ji/aRe+KHW+Rm+7kgeiXrHvf/kKeUP+gMVY=@vger.kernel.org, AJvYcCXPxehv7pOEk6ITLOW6Z1jNRQRUWCI+Tg3ZE9bI6Ksyvs08p7yzkwYFTbVE2Ganipgn3b079vh5SMd12Ms=@vger.kernel.org X-Gm-Message-State: AOJu0Yx27XaKX7ERZU/s6MEq9RBao+xS0YFwAuabfRetosQzaEfs0L1E xxoGsGZ4F7CywDm+TuRQNvdUkFdDGLXPn0ObVmOV4uR48Hzh4/KH X-Google-Smtp-Source: AGHT+IE/ddFu/z1GAxp7BaYUY9T8bKlWQ1dmYKRj6okptMgprtc/vsgg+nKiwNMQwuzo8WrR2It6Cg== X-Received: by 2002:a05:600c:1e22:b0:42c:b187:bdd5 with SMTP id 5b1f17b1804b1-42cb187c012mr97209215e9.22.1725987978861; Tue, 10 Sep 2024 10:06:18 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:18 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 02/11] media: i2c: ov5645: Use local `dev` pointer for subdev device assignment Date: Tue, 10 Sep 2024 18:06:01 +0100 Message-Id: <20240910170610.226189-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar While assigning the subdev device pointer, use the local `dev` pointer which is already extracted from the `i2c_client` pointer. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 6eedd0310b02..ab3a419df2df 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1187,7 +1187,7 @@ static int ov5645_probe(struct i2c_client *client) ov5645->sd.internal_ops = &ov5645_internal_ops; ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; ov5645->pad.flags = MEDIA_PAD_FL_SOURCE; - ov5645->sd.dev = &client->dev; + ov5645->sd.dev = dev; ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); From patchwork Tue Sep 10 17:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798966 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 86F7F1A2C1A; Tue, 10 Sep 2024 17:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987984; cv=none; b=iAnHLks2GZOF7vpSTv7a+AAObW7MJIrxkrxgQydJ7AwyT+hjKZkYhYwkCFhP3MyGINuYhCtKxF/W79lsCH7L2l6LjDKHMuWZkcOpiLi1t5EO6N3Ww0B85vtsQfBAPzIs36dGw7XtUQOCl/eExm9+M5+VpzNoQIJHhR672vhqUSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987984; c=relaxed/simple; bh=ZShCPWFSW/sqGfuamWtEEwCfgDxJvKsb2CpN+xf6TmM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FMFKxFJQzmfnKYL57EUJORk96Z9z5LDxd7Rvhbt4M+8fCQDbpdvss0uT7n1jNzWXuVtKyJfdyE4RYMDxFUI6oOPLc/vs0msXU+bJcK1QRm2W/U5Ox31oePcs4RgIfyfj2qZ4YRZOe1VXlO1bllmbS2A8qvePtxmtHYDKkgC9u5w= 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=jLhkHbz3; arc=none smtp.client-ip=209.85.221.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="jLhkHbz3" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-374bd0da617so673227f8f.3; Tue, 10 Sep 2024 10:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987981; x=1726592781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bviiKkM7wyJK2q4unJEl7wvx3EhZ5MDlCK2md31apcY=; b=jLhkHbz3vZDr+Un5Gdm1L9poYwmQBnVGx2kVz+Gj8keLorkEBkhDtBQ5NVUmmzHDvO O0ipz6ynmdfcovhiiTKvB0Olv3+nVPvIuhe6uus2UVr4Zr+SAAWA7Fjcto759K5B3a2b 1Q3JPed+LlLpNP0CMy5fdKHpPhre2fRPF2VsA5+r8MBoQViLAQ+SItk70tKDBGLHaC5v bfxTnLHcccjDxNtSJCquz9BEiskXSk96VhwoKZcqOgNwvd/rPGqEZUdFyYQ/0AIHu2UJ 7Ev8TafmW4CkPEQg2XgI+mCYVbMDoq5FE57y3hIoKv8X5GsxF3GcHixNVCG6S97g8g/q isDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987981; x=1726592781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bviiKkM7wyJK2q4unJEl7wvx3EhZ5MDlCK2md31apcY=; b=msyJee3gcQMCh0XsvsNMPJgb64fXaVNb2nItoEpKzcMu5Fn9yt0OMwebJbN+UoTSMz OknTs7jmUikd5soZpDEa7rgG1WP9PAhtBf9t/sGog1UqURdt4ClxkF/9IG+Ju8ykaBq1 GivPI5ExQA+SLhKQkzrSgOVbWGI6699LqrIrmI4qpkQeiz2u8Cj5ZQcQ4t+HMBiSR7J8 axrUsY7CWzEp7nA0kRI+wSVYvHRIfsMdISiAqpsVCy68mZh3dN/VXcNcK3Ym9vaaebh5 sI7/r8cHUoJ/e+/3l39dMU6VGXyV4yWXrLpelND2R1+DyB8akyrrJ0tl8863sq9hivVe mVdg== X-Forwarded-Encrypted: i=1; AJvYcCVswAo/aCrRLbDHLsRPXMsAPuqD1DXv+70vh7ELsRibZdYGMVgL3wgwbDYN2BaUFYx+GVPcLWwb7wqHxppuub3thaA=@vger.kernel.org, AJvYcCWNXwT/rYJrLahqyMNcgiQ88lAfSUdBWJlOX0QY71mQZQ3sjvFepjX3bFlWlVi/383EJJDyQ/DtLKuiXzw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5ZMERjPA3seFlItMJ89WAex2FZ44ciyv1QmqdhfzYYG5oklSG ds5Xt/rQo7ae3kb1fBxKqlLmn+LMhF4v49kJV0glRcoKo1rU+UfbL1rJiQ== X-Google-Smtp-Source: AGHT+IHIMx6tyFVJQibpsTviFVHZe9gUQGJCjmx48HNpYgN76ScWzQY/1kw2EAhKoYszBGEPkNhcWQ== X-Received: by 2002:a05:6000:50f:b0:378:7dc1:b22 with SMTP id ffacd0b85a97d-378b0791de5mr262940f8f.12.1725987980749; Tue, 10 Sep 2024 10:06:20 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:19 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 03/11] media: i2c: ov5645: Enable runtime PM after v4l2_async_register_subdev() Date: Tue, 10 Sep 2024 18:06:02 +0100 Message-Id: <20240910170610.226189-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar To simplify the probe error path, enable runtime PM after the v4l2_async_register_subdev() call. This change ensures that runtime PM is only enabled once the subdevice registration is successful, avoiding unnecessary cleanup in the error path. Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index ab3a419df2df..78b86438c798 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1239,18 +1239,17 @@ static int ov5645_probe(struct i2c_client *client) goto power_down; } - pm_runtime_set_active(dev); - pm_runtime_get_noresume(dev); - pm_runtime_enable(dev); - ov5645_init_state(&ov5645->sd, NULL); ret = v4l2_async_register_subdev(&ov5645->sd); if (ret < 0) { dev_err(dev, "could not register v4l2 device\n"); - goto err_pm_runtime; + goto power_down; } + 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); pm_runtime_mark_last_busy(dev); @@ -1258,9 +1257,6 @@ static int ov5645_probe(struct i2c_client *client) return 0; -err_pm_runtime: - pm_runtime_disable(dev); - pm_runtime_put_noidle(dev); power_down: ov5645_set_power_off(dev); free_entity: From patchwork Tue Sep 10 17:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798967 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.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 42C961A3BD3; Tue, 10 Sep 2024 17:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987987; cv=none; b=acOuCgJJPe9UZ5xPf4dxhYmNKlr04JmqxJtD9Z9SWlUCGmwxUDk2sB+oUeDBE4dQXAlUXzOEXWzdCKdeh+8OZZ9VY1izOciwbBpy/OzzfqARWanYPAln/eeIDBc756LSFHcBkg1+BEkR6XxNFTtNuAFHb4AjWhgqbGwDiViFg3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987987; c=relaxed/simple; bh=Zx3pVc2b4AnAFqjVntb6HlOm0c6VIoOxfvWt+DeZo3o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=odw1sGM4tMECNeycRbpvblWeqWiNW5NL7YCiiIVYprGG8Fia8z96aif40rbO7WuEVzw5SrAhTcKjRJcaR3t3/NJGhALLmfjITrML14R4RBpoQzDTmDVIXNIPT8++wA5AaD5r3AS6/yy9CBmC+AjrLzrUh5r/oSzoRDpS4zaBnnU= 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=diT24a0Z; arc=none smtp.client-ip=209.85.167.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="diT24a0Z" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-53661a131b4so4031046e87.1; Tue, 10 Sep 2024 10:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987982; x=1726592782; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1UAP/rOntP4qOrF9+5G6CAAVYJ5+O5YrbzDGPOIRXPU=; b=diT24a0Z9xl1SxnA4fzIJI17NiS57HtVZy6XKNotC8nRr0FU6E9KH0sWzfauxCI5Ru Gv8oLmrEOvWNAxmeR8JrN058VWbRb8YvCRGQv60NlkcWE/d+QxNIZ2m8yWRLkS6xo/QN n/+m8FtDXLN0/W+NAOso+S1eMOGlp1WJ2+zDeTA+nQO09qe+ywA8AixwY3/c58HHbrNt DWFm9Jar2ANI+vQIM+057MgaDU3yegcIiqEWCveobBt7ttU2+vYGScuP2d55HoEtp9EI H5LeoAt21dhKFlumkUccBa4gwR1o0fKW4vMmXk5uqsHKuh9A2a/dsD4m4D8Mr/2kRkcB PaPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987982; x=1726592782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1UAP/rOntP4qOrF9+5G6CAAVYJ5+O5YrbzDGPOIRXPU=; b=SyAR2SlUdJGDthTo+JpAjCPblt5Y/6Q1leAjGjngIFk6u6TR5j4hZ7tQqiEAJF+nIm lOIh69TpCC2IQFYamNtcftHRHoCZfg7Y97uqaxubH0kZkocExvHCb+JcKHSZG+JuEJ7E vbDuS68Z8fL8kJU8ap6JZNLBFK350PAbtig4OLSBjfYcse/4V6cbJDqDaO8R5PvlA/Il Z5sjmscOrEKDSBuQgp0Ch8JJdSOM7zoEXoaWmwCc1m80Pt0sL7EhzzN22sIoK92LNdBj 7ZoZboF7dymsx9eDBHqb2fomwIb5weXxVkrfnVt5ykPse8tLoKzgVtmsEOnNkwNy+vC+ kIlw== X-Forwarded-Encrypted: i=1; AJvYcCVPyqdOFC1Ua7AdGVPlRwCipXCv4Ci3sak9LH+mRV36BqK7fPP8bYouUoV6b6wTS6cE8AefKLd8UvAOxyl0hiEGPu8=@vger.kernel.org, AJvYcCVoYdbmlfBxhZtlSJjaLcpaTm5ifVzGqfRyGyX3ec8iL4Ieph4+Zrh45T/YgzSrdusslCqNkthmuigTRiw=@vger.kernel.org X-Gm-Message-State: AOJu0YwIV6iY7ewyyVBZmq/B9Ozpc/LoeB/P6B5Ne6UTnvb9Dc9KwL78 rbX8zjAg1hrRpszzdEmIFr9Xv2PKOG6VtCzaXaEfsbUd8eopVKS2 X-Google-Smtp-Source: AGHT+IGmShqFyHM8JrfCwRA8tVcctYpiWEFyfpNyqpdz5qs5PVm2XykcOyIlUyrpFRk3fyie5spYMQ== X-Received: by 2002:a05:6512:3b2a:b0:530:aa82:a50a with SMTP id 2adb3069b0e04-536587fc670mr9344826e87.45.1725987982070; Tue, 10 Sep 2024 10:06:22 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:21 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 04/11] media: i2c: ov5645: Use dev_err_probe instead of dev_err Date: Tue, 10 Sep 2024 18:06:03 +0100 Message-Id: <20240910170610.226189-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Drop dev_err() and use the dev_err_probe() helper on probe path. Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 74 +++++++++++++++----------------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 78b86438c798..9e6ff1f1b9ac 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1076,51 +1076,37 @@ static int ov5645_probe(struct i2c_client *client) ov5645->dev = dev; endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - if (!endpoint) { - dev_err(dev, "endpoint node not found\n"); - return -EINVAL; - } + if (!endpoint) + return dev_err_probe(dev, -EINVAL, "endpoint node not found\n"); ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), &ov5645->ep); of_node_put(endpoint); - if (ret < 0) { - dev_err(dev, "parsing endpoint node failed\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "parsing endpoint node failed\n"); - if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) { - dev_err(dev, "invalid bus type, must be CSI2\n"); - return -EINVAL; - } + if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) + return dev_err_probe(dev, -EINVAL, "invalid bus type, must be CSI2\n"); /* get system clock (xclk) */ ov5645->xclk = devm_clk_get(dev, NULL); - if (IS_ERR(ov5645->xclk)) { - dev_err(dev, "could not get xclk"); - return PTR_ERR(ov5645->xclk); - } + if (IS_ERR(ov5645->xclk)) + return dev_err_probe(dev, PTR_ERR(ov5645->xclk), "could not get xclk"); ret = of_property_read_u32(dev->of_node, "clock-frequency", &xclk_freq); - if (ret) { - dev_err(dev, "could not get xclk frequency\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "could not get xclk frequency\n"); /* external clock must be 24MHz, allow 1% tolerance */ - if (xclk_freq < 23760000 || xclk_freq > 24240000) { - dev_err(dev, "external clock frequency %u is not supported\n", - xclk_freq); - return -EINVAL; - } + if (xclk_freq < 23760000 || xclk_freq > 24240000) + return dev_err_probe(dev, -EINVAL, "external clock frequency %u is not supported\n", + xclk_freq); ret = clk_set_rate(ov5645->xclk, xclk_freq); - if (ret) { - dev_err(dev, "could not set xclk frequency\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "could not set xclk frequency\n"); for (i = 0; i < OV5645_NUM_SUPPLIES; i++) ov5645->supplies[i].supply = ov5645_supply_name[i]; @@ -1131,16 +1117,12 @@ static int ov5645_probe(struct i2c_client *client) return ret; ov5645->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); - if (IS_ERR(ov5645->enable_gpio)) { - dev_err(dev, "cannot get enable gpio\n"); - return PTR_ERR(ov5645->enable_gpio); - } + if (IS_ERR(ov5645->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(ov5645->enable_gpio), "cannot get enable gpio\n"); ov5645->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(ov5645->rst_gpio)) { - dev_err(dev, "cannot get reset gpio\n"); - return PTR_ERR(ov5645->rst_gpio); - } + if (IS_ERR(ov5645->rst_gpio)) + return dev_err_probe(dev, PTR_ERR(ov5645->rst_gpio), "cannot get reset gpio\n"); mutex_init(&ov5645->power_lock); @@ -1177,9 +1159,9 @@ static int ov5645_probe(struct i2c_client *client) ov5645->sd.ctrl_handler = &ov5645->ctrls; if (ov5645->ctrls.error) { - dev_err(dev, "%s: control initialization error %d\n", - __func__, ov5645->ctrls.error); ret = ov5645->ctrls.error; + dev_err_probe(dev, ret, "%s: control initialization error %d\n", + __func__, ov5645->ctrls.error); goto free_ctrl; } @@ -1192,7 +1174,7 @@ static int ov5645_probe(struct i2c_client *client) ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); if (ret < 0) { - dev_err(dev, "could not register media entity\n"); + dev_err_probe(dev, ret, "could not register media entity\n"); goto free_ctrl; } @@ -1202,14 +1184,14 @@ static int ov5645_probe(struct i2c_client *client) ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_HIGH, &chip_id_high); if (ret < 0 || chip_id_high != OV5645_CHIP_ID_HIGH_BYTE) { - dev_err(dev, "could not read ID high\n"); ret = -ENODEV; + dev_err_probe(dev, ret, "could not read ID high\n"); goto power_down; } ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_LOW, &chip_id_low); if (ret < 0 || chip_id_low != OV5645_CHIP_ID_LOW_BYTE) { - dev_err(dev, "could not read ID low\n"); ret = -ENODEV; + dev_err_probe(dev, ret, "could not read ID low\n"); goto power_down; } @@ -1218,24 +1200,24 @@ static int ov5645_probe(struct i2c_client *client) ret = ov5645_read_reg(ov5645, OV5645_AEC_PK_MANUAL, &ov5645->aec_pk_manual); if (ret < 0) { - dev_err(dev, "could not read AEC/AGC mode\n"); ret = -ENODEV; + dev_err_probe(dev, ret, "could not read AEC/AGC mode\n"); goto power_down; } ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG20, &ov5645->timing_tc_reg20); if (ret < 0) { - dev_err(dev, "could not read vflip value\n"); ret = -ENODEV; + dev_err_probe(dev, ret, "could not read vflip value\n"); goto power_down; } ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG21, &ov5645->timing_tc_reg21); if (ret < 0) { - dev_err(dev, "could not read hflip value\n"); ret = -ENODEV; + dev_err_probe(dev, ret, "could not read hflip value\n"); goto power_down; } @@ -1243,7 +1225,7 @@ static int ov5645_probe(struct i2c_client *client) ret = v4l2_async_register_subdev(&ov5645->sd); if (ret < 0) { - dev_err(dev, "could not register v4l2 device\n"); + dev_err_probe(dev, ret, "could not register v4l2 device\n"); goto power_down; } From patchwork Tue Sep 10 17:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798968 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 38C881A4AA4; Tue, 10 Sep 2024 17:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987987; cv=none; b=AskC60uLPyXxYY73KnVnQ+47bumebL4RzcZYJglZq2Ji9Ev9otoV2d/x1IfasbKHjxakhhXy9G5Ado7a6R2FCEiZoihpi23t1MZzuegDLpimpMANav0CZH3Ko+f3pGTPkxqIpnwiF8DGd789sPxGQfKW65ysmopp0mA079dRJoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987987; c=relaxed/simple; bh=Kiv17uNGthDImT4AMacEgbQWK5UrKLL4azvkUaL16aU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rn7chlPzts/kgCN+Q19c2726LpS3tTXQ5vS50E/sTiOtA9SDrX4cO07M57b80tetwMTH2CySFAMytqduKiGjb+mK6tJKtcyVXztquwkAKXGlXja4VOkhMcpDienybHXMa3vbgZQUV4TG1MJUEaHntxqmirv4dows+6+09WcqZhI= 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=TMmuvmh5; arc=none smtp.client-ip=209.85.128.43 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="TMmuvmh5" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42cbc22e1c4so14730275e9.2; Tue, 10 Sep 2024 10:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987983; x=1726592783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qbuGE6Z/iK7gyKdugxbHWm8tH5fwf4V7+4tVK51cDIA=; b=TMmuvmh5i2h7e5LHsUI3ybin8e32LMFCqm1qeiAvnHaCZLp8OGqEArLcvFiA51QT13 CLvmYOZ00t9SUZsyqXa7ERtXtHoYrYdQ5cqfKmVNXLfccU6jJXZpt4R8A4M6q7eJbByu obOWPl1LdUhELEN6Wep5Np8y1AMvnlxv5DgaO++FOPtUcA3TFfxP2BY5hfLbnoiWhW4T 4mq1HOXusDeH0h9YOGC1GsOXR8s3kNNOTPO/MmnQZSRi5N7M5ryJGhIjafITgIMIgNv8 fML3cSOI4kLBB/P3Nsn3NtNQ1cNfie6E26A2B2Ia/2sBorrnIO3uIJa6SBTtSE1D8h05 9ljw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987983; x=1726592783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qbuGE6Z/iK7gyKdugxbHWm8tH5fwf4V7+4tVK51cDIA=; b=gPOa8w9fMB/ip8GUTasf7ROsAA2kuLXtFI4+su42EBLYT0jBors/UwvzLiYf3jxXh0 +pbXFAp2baFoWSPOHiDzTIPI2SFcvDuk2vEULCKdl0IdVwQ40sk01iWiamZpBgAAuALt XYlzsy6WA8p+r4IIXqLx+yBbB9sVQEwoGbFZ04FayODvXDYP92Ghb+fbHYlDQdleX5Za pyTLH5+FAVV247LLyIANUWuZZhEVD/Sghr1992+RrMmh0MlltLloTWNp5Fd5htQ9MHXs 8DqzHq1xQLs3aRKLqkSiOEBp9wk4X73FLimvp6dJX0/lC4Sxnv+yfWh6l1sRWXx6E15G G4OQ== X-Forwarded-Encrypted: i=1; AJvYcCUuhwtxBnEGOmSrKoSvrd7V/DfWWkefOxtWDcWouumN5rfJoTWzqIcn0/Th+f1sSTd7OkmeHh4o2V+r2Ls=@vger.kernel.org, AJvYcCXjqzUdEB38y6eNdrUcJ78xZqeF2A2v5I9ilPnWDsoYQolcRffXMIL9wuGQUEAN45qEnp4gQqIOZ034+ZDcIyL+PMY=@vger.kernel.org X-Gm-Message-State: AOJu0YzqB0b6AZxVyTYknsMpGDy/G9sq3ebtSx4luMGmcY5LHhyf/Cnx VmNsGstOL3DITFln9hVSdJW2efSqmWQq+CAF4rhAxZ+pU3pSuMj9 X-Google-Smtp-Source: AGHT+IEswm6La4EzEWhNFU2RPVCnYzqnXEXKsbo6y5trocbjO7FWGhqWOfirTDT+flFELtTsIALGDQ== X-Received: by 2002:a05:600c:1c03:b0:428:36e:be59 with SMTP id 5b1f17b1804b1-42cae70f2b9mr82363625e9.11.1725987983481; Tue, 10 Sep 2024 10:06:23 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:22 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 05/11] media: i2c: ov5645: Use v4l2_async_register_subdev_sensor() Date: Tue, 10 Sep 2024 18:06:04 +0100 Message-Id: <20240910170610.226189-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Make use v4l2_async_register_subdev_sensor() helper to register the subdev. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 9e6ff1f1b9ac..45687d004004 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -1223,7 +1223,7 @@ static int ov5645_probe(struct i2c_client *client) ov5645_init_state(&ov5645->sd, NULL); - ret = v4l2_async_register_subdev(&ov5645->sd); + ret = v4l2_async_register_subdev_sensor(&ov5645->sd); if (ret < 0) { dev_err_probe(dev, ret, "could not register v4l2 device\n"); goto power_down; From patchwork Tue Sep 10 17:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798969 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 C6A911A4AD7; Tue, 10 Sep 2024 17:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987988; cv=none; b=Rjncc0hJab/yugz2V0jDK2UPW00G2TjbwUU/4sc3h7NQuymPOFIuYZodOZij0ELnOGBRfU54zOUbL8PUL5UJEtKSKimX6250GBu8lgVlPdtBPZIRAo6S2V1sN+xNo7gbyaaFgMmJxHuGk0crkOMWXCS2D9lBpSz37C6L91sbCLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987988; c=relaxed/simple; bh=mAqO79O3l/OvTSDmMNjmx02R4NEoM9pQ3zCM/ZFlJSg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OlzngoRdM+FySQ3/sS4YvcWF0oe4NtilOBovOki8qmWOEMFHh40JuYpfdWTlELIQb61iFQMRI7MsOLz5KFqVP2R6tV/tvNKTchEhJO3VJLtxGdN5qgcmiEIRVlw/Db2F4HN1nJ5znUVjsBc8oxO8baNKvNFu5AmcgLOuHaz/YqY= 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=NjLR4I1b; arc=none smtp.client-ip=209.85.221.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="NjLR4I1b" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-374c4c6cb29so5177158f8f.3; Tue, 10 Sep 2024 10:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987985; x=1726592785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QlCGmlbK8knhiNdPKYD3AWEcb7dTp9/GfV8SpqAQwLI=; b=NjLR4I1b1vNKWbuqDbPd33q9bMMo8GFAIb+aH9RqSzjNMqnQHe7FfMEVrd9A3qwIC/ +DTbvbMjJ3kJBbLRE+n5iYHWxX1pNATDJlp/RMbA4lfHk0FHAENx9AVqFFGJLV1NnIlQ 7LCTkF60b4TY6fnSDtLLjU/PBaYZ22+n1x/ivcdFOR4i21PqNvkw/YoNbxDTwOmnrDqO Scq6pM4ioSVm1jm8rusab0YCPqg8bVHMgagek2Lz5mCniDpeCVebsaZ74U1weRtg3jUb wwHYBO4ynxzx6yuLM37jM8FHR4WINKSWkLskfJ4juP/YBxEkGRFpnL3ccCqC3p0Bjday fh7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987985; x=1726592785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QlCGmlbK8knhiNdPKYD3AWEcb7dTp9/GfV8SpqAQwLI=; b=t7YqWNJhkeOmQzup++bhVYpJ2IDD/8TYR4YyBqgmpqQNPQna0N6sVCU8Zb/Wfml9MG e6XVa4j8eB5ZuckMvv1Lm8G3s6FR0qvCgZtkSF3rUu8YxZy/SZlHTyVPl+DPh4aP/G7L o8aSD5yQ1dj/lyLAMcmUHEOoDfDmHH1TrMXI8IHlk4aXU+zpVWdUzzvGr6CVLbJ6gVuM KB74oZoJkIQEWkZXW9xQlPnekHzyD5iFFwT3pjhfXw9uN/4vSykufCIfXGPb0G0yHrp5 vSpRHABtCqDY8qlnLC5naM0DhL/DzN/7webi2FKiv0jo/6b7MSR0hSHZJLGG1PPLnmiJ Puag== X-Forwarded-Encrypted: i=1; AJvYcCVByyhP5G4HkaTe8wXZUrBwZGJ+Na48l4eHRU1WZNAbXWIvQv4VB2aeNSFWMbEDiD+AyIuR/rvTf0KGKpk=@vger.kernel.org, AJvYcCWbPZDsPKR+trcmsFCdK/cxprBjIVarOmrHiwRzoPdy3vmx9GGxW5u556+88IWvYhDQljgiPbrAlaZdzJu96pB1ZGQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yyg8Mp3ywdjJ+cQvsCfo/VNY5kXCfaYV3hCFrvj7eZ6U9nR6xAe ERyBHDGMaEgm0cSTn73xPT2Wrn0PwYydnyjSJ8PGCsKnPJ/aqPPr X-Google-Smtp-Source: AGHT+IFJ18NP6xZuWGZfWy6nwzJBgaGs+52ZtI9KSSEYZxPmtL4+Gc4LfrAvXiDM4guD2wSo+ngvJA== X-Received: by 2002:adf:a413:0:b0:374:c7a5:d610 with SMTP id ffacd0b85a97d-3789243fbc7mr9707544f8f.43.1725987984910; Tue, 10 Sep 2024 10:06:24 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:23 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 06/11] media: i2c: ov5645: Drop `power_lock` mutex Date: Tue, 10 Sep 2024 18:06:05 +0100 Message-Id: <20240910170610.226189-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Drop mutex while applying controls and just rely on pm_runtime_get_if_in_use() call. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 45687d004004..25c60afcc0ec 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -106,8 +106,6 @@ struct ov5645 { u8 timing_tc_reg20; u8 timing_tc_reg21; - struct mutex power_lock; /* lock to protect power state */ - struct gpio_desc *enable_gpio; struct gpio_desc *rst_gpio; }; @@ -782,11 +780,8 @@ static int ov5645_s_ctrl(struct v4l2_ctrl *ctrl) struct ov5645, ctrls); int ret; - mutex_lock(&ov5645->power_lock); - if (!pm_runtime_get_if_in_use(ov5645->dev)) { - mutex_unlock(&ov5645->power_lock); + if (!pm_runtime_get_if_in_use(ov5645->dev)) return 0; - } switch (ctrl->id) { case V4L2_CID_SATURATION: @@ -817,7 +812,6 @@ static int ov5645_s_ctrl(struct v4l2_ctrl *ctrl) pm_runtime_mark_last_busy(ov5645->dev); pm_runtime_put_autosuspend(ov5645->dev); - mutex_unlock(&ov5645->power_lock); return ret; } @@ -1124,8 +1118,6 @@ static int ov5645_probe(struct i2c_client *client) if (IS_ERR(ov5645->rst_gpio)) return dev_err_probe(dev, PTR_ERR(ov5645->rst_gpio), "cannot get reset gpio\n"); - mutex_init(&ov5645->power_lock); - v4l2_ctrl_handler_init(&ov5645->ctrls, 9); v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, V4L2_CID_SATURATION, -4, 4, 1, 0); @@ -1245,7 +1237,6 @@ static int ov5645_probe(struct i2c_client *client) media_entity_cleanup(&ov5645->sd.entity); free_ctrl: v4l2_ctrl_handler_free(&ov5645->ctrls); - mutex_destroy(&ov5645->power_lock); return ret; } @@ -1262,7 +1253,6 @@ static void ov5645_remove(struct i2c_client *client) if (!pm_runtime_status_suspended(ov5645->dev)) ov5645_set_power_off(ov5645->dev); pm_runtime_set_suspended(ov5645->dev); - mutex_destroy(&ov5645->power_lock); } static const struct i2c_device_id ov5645_id[] = { From patchwork Tue Sep 10 17:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798970 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 DDB0F1A4F03; Tue, 10 Sep 2024 17:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987989; cv=none; b=CFh56m/XldJ4ATK+DuICbfFT1DFpxNKy9NseyalxxLHs+t+LCnjBw5zCIhZcTB2nNoj3CiKnXXn6bfVUYsyQemE2h5JhnuCfNtqbUO/nw+RkUHHqw7D3YnWWjSxrzPThj6p6BJg3Ops6I6DCecKbKrb2pdG2/BriVadwgksCrio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987989; c=relaxed/simple; bh=Ht70IJcyQJH4Dhqjjac98yUwsL35MwaRODP3k/kTeYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b0gy32fRZXhXCHsbqcIKhvhqweeFkYIdkg+2qy93LHqG0kqSsAB7ZiDqEtVGe3tMM9DsHpHhO3Zcv1uFbIo/ktDV9VWB3Ies1SqhfcW6HRhsQNwOV8OxzZpC1OH/r1+08ByHVaTEJPzw6rKefTCHXLH9ufual4feCmxuUf3K9Qw= 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=iwXNqiJX; arc=none smtp.client-ip=209.85.128.44 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="iwXNqiJX" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42cae102702so32919715e9.0; Tue, 10 Sep 2024 10:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987986; x=1726592786; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a8uiJ1o1t/FLwtZAsye5lzWDkjfsKX1SsElvPj0kYXM=; b=iwXNqiJXW3/ttAL1syJ2dBhU+MdQCNlE6mpIiViyEoZwX4Gf7UZjq5FFzYSYMYq/gd 3OmOOOIqatrEFiFVoFMrN/62l5FAiQV2yzgdqdJhEBTjne6v2JdWTD2Irwj/EnQwNCKh eXiPbBRtlQNYpy7tVgcyIt/odidEk3TFZXiwxsiIlnBkbYp70AWde1oIAEwlLSEsRAKf FY6H+l8Meep3WEXH57Zj4G9423vi1aHvsgaIKtXO2IikzFgSIyGiIth4ZhvQG8vLNCH5 b1Y7521cNQnGnxTys5GmhsXBadjWOUZkr1zvveSOvsnqO8mtRHgbcm1NmmobNaOqQg9a QHUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987986; x=1726592786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a8uiJ1o1t/FLwtZAsye5lzWDkjfsKX1SsElvPj0kYXM=; b=wLrRZZbpU+7Vo1KmBAIem3uFPa5Qm0Hqy1TVx66s+e01aLTiTzCD2oIXgP9Utfr4Og DSwOj56Lw+02xQ9UEV51h3fciBSmELOfOkHkCuJFl+u/xq6RJsAMywV5krg6aDaw+ncC 09zS1dl+YgX0eKZPih60C5lhEcaGZ9PMLtauoK4Qmrf6tuqqfdlMffrRzmhDv1fCby0H vrHkdJ2+6DMeo7wEClehkgzjLmsCEY3YAaXoYGhHf8C39dAfZim9UYP/v3tSjczz84du CMs4MaHo4DzTp4URCFDGOG/X6WNBgDgtfk00NRHIr6jPXNv2mkd+5UIY86V0YwM9k657 4kOg== X-Forwarded-Encrypted: i=1; AJvYcCUNBIa9INr+tleLPuYTMd6/fJH8UIQX/pO69d4xuJ6idTyE8A9ajaT65NrzyxRtjjlLXqdLAWvBECZ7YrU=@vger.kernel.org, AJvYcCXbuULKOUE5LURgibE48Upd3gH98XjMutBpc2DY274IpvfaZxaNtBu5j6bsWhtGtQIAbezZHD4o+pP18NmIIDK2fzI=@vger.kernel.org X-Gm-Message-State: AOJu0YyRd6CEDfimPigB6Y3xkk4FWysvZPhfEsB8xxIiZjjB63eQ6hgE 8xYgetgtIZC6FpnyeD6aeN+genM6reEn5Alc11KSQGQoOSIF6zXn X-Google-Smtp-Source: AGHT+IEDInuqJcMsepKgHn0+SNH1/ulUDsHynSJ9ODSmro1CkMvbhI09v88zXoxQUZ2gXW80Vl4sAA== X-Received: by 2002:a05:600c:1c0f:b0:428:1b0d:8657 with SMTP id 5b1f17b1804b1-42cae73e0a1mr82103645e9.22.1725987986172; Tue, 10 Sep 2024 10:06:26 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:25 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 07/11] media: i2c: ov5645: Use subdev active state Date: Tue, 10 Sep 2024 18:06:06 +0100 Message-Id: <20240910170610.226189-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Port the ov5645 sensor driver to use the subdev active state. Move all the format configuration to the subdevice state and simplify the format handling, locking and initialization. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 109 +++++++++++++------------------------ 1 file changed, 39 insertions(+), 70 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 25c60afcc0ec..9497ec737cb7 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -89,7 +89,6 @@ struct ov5645 { struct v4l2_subdev sd; struct media_pad pad; struct v4l2_fwnode_endpoint ep; - struct v4l2_mbus_framefmt fmt; struct v4l2_rect crop; struct clk *xclk; @@ -850,49 +849,6 @@ static int ov5645_enum_frame_size(struct v4l2_subdev *subdev, return 0; } -static struct v4l2_mbus_framefmt * -__ov5645_get_pad_format(struct ov5645 *ov5645, - struct v4l2_subdev_state *sd_state, - unsigned int pad, - enum v4l2_subdev_format_whence which) -{ - switch (which) { - case V4L2_SUBDEV_FORMAT_TRY: - return v4l2_subdev_state_get_format(sd_state, pad); - case V4L2_SUBDEV_FORMAT_ACTIVE: - return &ov5645->fmt; - default: - return NULL; - } -} - -static int ov5645_get_format(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *format) -{ - struct ov5645 *ov5645 = to_ov5645(sd); - - format->format = *__ov5645_get_pad_format(ov5645, sd_state, - format->pad, - format->which); - return 0; -} - -static struct v4l2_rect * -__ov5645_get_pad_crop(struct ov5645 *ov5645, - struct v4l2_subdev_state *sd_state, - unsigned int pad, enum v4l2_subdev_format_whence which) -{ - switch (which) { - case V4L2_SUBDEV_FORMAT_TRY: - return v4l2_subdev_state_get_crop(sd_state, pad); - case V4L2_SUBDEV_FORMAT_ACTIVE: - return &ov5645->crop; - default: - return NULL; - } -} - static int ov5645_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *format) @@ -903,33 +859,30 @@ static int ov5645_set_format(struct v4l2_subdev *sd, const struct ov5645_mode_info *new_mode; int ret; - __crop = __ov5645_get_pad_crop(ov5645, sd_state, format->pad, - format->which); - + __crop = v4l2_subdev_state_get_crop(sd_state, 0); new_mode = v4l2_find_nearest_size(ov5645_mode_info_data, - ARRAY_SIZE(ov5645_mode_info_data), - width, height, - format->format.width, format->format.height); + ARRAY_SIZE(ov5645_mode_info_data), + width, height, format->format.width, + format->format.height); __crop->width = new_mode->width; __crop->height = new_mode->height; if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { - ret = v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock, - new_mode->pixel_clock); + ret = __v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock, + new_mode->pixel_clock); if (ret < 0) return ret; - ret = v4l2_ctrl_s_ctrl(ov5645->link_freq, - new_mode->link_freq); + ret = __v4l2_ctrl_s_ctrl(ov5645->link_freq, + new_mode->link_freq); if (ret < 0) return ret; ov5645->current_mode = new_mode; } - __format = __ov5645_get_pad_format(ov5645, sd_state, format->pad, - format->which); + __format = v4l2_subdev_state_get_format(sd_state, 0); __format->width = __crop->width; __format->height = __crop->height; __format->code = MEDIA_BUS_FMT_UYVY8_1X16; @@ -944,11 +897,15 @@ static int ov5645_set_format(struct v4l2_subdev *sd, static int ov5645_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state) { - struct v4l2_subdev_format fmt = { 0 }; - - fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; - fmt.format.width = 1920; - fmt.format.height = 1080; + struct v4l2_subdev_format fmt = { + .which = V4L2_SUBDEV_FORMAT_TRY, + .pad = 0, + .format = { + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .width = ov5645_mode_info_data[1].width, + .height = ov5645_mode_info_data[1].height, + }, + }; ov5645_set_format(subdev, sd_state, &fmt); @@ -959,25 +916,27 @@ static int ov5645_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) { - struct ov5645 *ov5645 = to_ov5645(sd); - if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - sel->r = *__ov5645_get_pad_crop(ov5645, sd_state, sel->pad, - sel->which); + sel->r = *v4l2_subdev_state_get_crop(sd_state, 0); return 0; } static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable) { struct ov5645 *ov5645 = to_ov5645(subdev); + struct v4l2_subdev_state *state; int ret; + state = v4l2_subdev_lock_and_get_active_state(&ov5645->sd); + if (enable) { ret = pm_runtime_resume_and_get(ov5645->dev); - if (ret < 0) + if (ret < 0) { + v4l2_subdev_unlock_state(state); return ret; + } ret = ov5645_set_register_array(ov5645, ov5645->current_mode->data, @@ -988,7 +947,7 @@ static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable) ov5645->current_mode->height); goto err_rpm_put; } - ret = v4l2_ctrl_handler_setup(&ov5645->ctrls); + ret = __v4l2_ctrl_handler_setup(&ov5645->ctrls); if (ret < 0) { dev_err(ov5645->dev, "could not sync v4l2 controls\n"); goto err_rpm_put; @@ -1013,6 +972,7 @@ static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable) goto stream_off_rpm_put; } + v4l2_subdev_unlock_state(state); return 0; err_rpm_put: @@ -1022,6 +982,7 @@ static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable) stream_off_rpm_put: pm_runtime_mark_last_busy(ov5645->dev); pm_runtime_put_autosuspend(ov5645->dev); + v4l2_subdev_unlock_state(state); return ret; } @@ -1032,7 +993,7 @@ static const struct v4l2_subdev_video_ops ov5645_video_ops = { static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { .enum_mbus_code = ov5645_enum_mbus_code, .enum_frame_size = ov5645_enum_frame_size, - .get_fmt = ov5645_get_format, + .get_fmt = v4l2_subdev_get_fmt, .set_fmt = ov5645_set_format, .get_selection = ov5645_get_selection, }; @@ -1213,12 +1174,17 @@ static int ov5645_probe(struct i2c_client *client) goto power_down; } - ov5645_init_state(&ov5645->sd, NULL); + ov5645->sd.state_lock = ov5645->ctrls.lock; + ret = v4l2_subdev_init_finalize(&ov5645->sd); + if (ret < 0) { + dev_err_probe(dev, ret, "subdev init error\n"); + goto power_down; + } ret = v4l2_async_register_subdev_sensor(&ov5645->sd); if (ret < 0) { dev_err_probe(dev, ret, "could not register v4l2 device\n"); - goto power_down; + goto error_subdev_cleanup; } pm_runtime_set_active(dev); @@ -1231,6 +1197,8 @@ static int ov5645_probe(struct i2c_client *client) return 0; +error_subdev_cleanup: + v4l2_subdev_cleanup(&ov5645->sd); power_down: ov5645_set_power_off(dev); free_entity: @@ -1247,6 +1215,7 @@ static void ov5645_remove(struct i2c_client *client) struct ov5645 *ov5645 = to_ov5645(sd); v4l2_async_unregister_subdev(&ov5645->sd); + v4l2_subdev_cleanup(sd); media_entity_cleanup(&ov5645->sd.entity); v4l2_ctrl_handler_free(&ov5645->ctrls); pm_runtime_disable(ov5645->dev); From patchwork Tue Sep 10 17:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798971 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 25D4B1A7048; Tue, 10 Sep 2024 17:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987990; cv=none; b=f4Vkt8HYq3iHyLG0kCQxhuSsFTI4LsErGdbBavKffjZXQ7VUCNzpBivw+qlRjObR1XrHMAaTy8sxxOUHcA2DIfc1vQZet8nt0nP1QkiYXQ85pVzz3W14G0llNyyLTP4fRDMPor/iuXyTnLnuUBzUaOPN00RPA+WXqQNQksdM9qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987990; c=relaxed/simple; bh=TlPMS9+iyWeF7BUutFeeBinJP2I92tXInMXqr1sU1PQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AQikRwfxzjW2YbuttQ58dFh+3QZ0U7SlIvtPC4f0aooqYMVx1dZigMEqQRMrelJMTgy3tJ6+FZXsU632B03MK7sG0RU2oRIJemjzFV/zCl9J1LorIoSBo1Veq5IigAKp3tQe4jgy5cjqhrbIdYE05NnKv5OHA5p/9yZGqnwzERc= 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=UNrRkBzT; arc=none smtp.client-ip=209.85.221.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="UNrRkBzT" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-374ca7a10d4so3525431f8f.3; Tue, 10 Sep 2024 10:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987987; x=1726592787; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XOCHN3EnOjt3dKmVD+Yk25XhtTBnkoSrJQy1+RtOVLc=; b=UNrRkBzTMGcU3bD07HJDJ3Wez5xZfy8oYHumMB+8BnDK5Tswjw6kE2gCBrZJFIkXJF 4m1QSLO82q2gLwI/TexF3Yh8fb7nORbGndY5bWM/BLShHCs8MgERaO/zyt3tBPKEq6jO ath1jBKWiIwtt7kGCeVdecFnrjJtszVUmcVSKQHDc/42kTbY5YMzPZXXW6YcrYrU5SqQ irKFARXAUmLPpadO5HU+SsrcJxtxZ38FcCtj04oyOeQi1NTAGz9ht7mXP65UIiEANdox MiQowe+e5kew73aZjAk8TfArnWOT9+7at14xBHHyUhiIlCJqFnxVM3tRl+1BViGGLxFF 9upQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987987; x=1726592787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XOCHN3EnOjt3dKmVD+Yk25XhtTBnkoSrJQy1+RtOVLc=; b=emTvKiZc/2LGjhGoSMFotmIh6rUVjs6MxdzV935/8pp4TqorDwkbQ44qC5LDrdBnE9 orfcB31Bt6lPXbOa4CG6q/qxqr1EAZ0axSAWxe/16+BsYODHIMoxMeZbw/5xqmAsqJkz CTiey+a6iKbXhGfLBfTryGsIOI+++JtwNmGTFqxXi2BVt/j9EvWo9Zwf7P15WUjUe4YU YvN4OjPakZg7LZXk3YajIqTo33e1axQUvUmfVwDCzmYC2g3yiLr2uGO/hPrXbdB8aR7j iQzI1/EgJJNxPX1oRuUp5pLO4VNDIVQDwiWyUCU8sCQiJCAhTPNKItrqdB+/o//DrGZv OtrQ== X-Forwarded-Encrypted: i=1; AJvYcCU++hDXXliu9OqFf6p+wgWvJgfy1KAXAviykD4DZp3ih0NF2BRQk/0PnQi+nNqfIyLP/nb+CvBYe6aTh44=@vger.kernel.org, AJvYcCU2W9LzgnWUFwBzhVuu13m3VRA2lAyA4PmHKlmOcaRhzfJ4nYF0mwEpA4GhAW/K9rU4UAK0tG7n9TyVuQzriT5Yf1U=@vger.kernel.org X-Gm-Message-State: AOJu0YwTFHteUWWJCLTz0EjWPl1C66TkwqvNfmWDWdIhs7ckEXS6MM9t mmmhvae+x8kkv5SUw+vapi+Jyrj5+hq5qfN1icNTBRXZYJwRs0px X-Google-Smtp-Source: AGHT+IFCaV2AU6aqCZboX5KGlyOq3otygjt59UuHU9Mo9CF+xjHrUtYmOPoP/qLilU30QZ97MlQFwA== X-Received: by 2002:a05:6000:1249:b0:376:efb7:d19a with SMTP id ffacd0b85a97d-37892703efcmr7082438f8f.44.1725987987438; Tue, 10 Sep 2024 10:06:27 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:26 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 08/11] media: i2c: ov5645: Switch to {enable,disable}_streams Date: Tue, 10 Sep 2024 18:06:07 +0100 Message-Id: <20240910170610.226189-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Switch from s_stream to enable_streams and disable_streams callbacks. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 90 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 9497ec737cb7..dc93514608ee 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -923,71 +923,71 @@ static int ov5645_get_selection(struct v4l2_subdev *sd, return 0; } -static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable) +static int ov5645_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { - struct ov5645 *ov5645 = to_ov5645(subdev); - struct v4l2_subdev_state *state; + struct ov5645 *ov5645 = to_ov5645(sd); int ret; - state = v4l2_subdev_lock_and_get_active_state(&ov5645->sd); - - if (enable) { - ret = pm_runtime_resume_and_get(ov5645->dev); - if (ret < 0) { - v4l2_subdev_unlock_state(state); - return ret; - } + ret = pm_runtime_resume_and_get(ov5645->dev); + if (ret < 0) + return ret; - ret = ov5645_set_register_array(ov5645, + ret = ov5645_set_register_array(ov5645, ov5645->current_mode->data, ov5645->current_mode->data_size); - if (ret < 0) { - dev_err(ov5645->dev, "could not set mode %dx%d\n", - ov5645->current_mode->width, - ov5645->current_mode->height); - goto err_rpm_put; - } - ret = __v4l2_ctrl_handler_setup(&ov5645->ctrls); - if (ret < 0) { - dev_err(ov5645->dev, "could not sync v4l2 controls\n"); - goto err_rpm_put; - } - - ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x45); - if (ret < 0) - goto err_rpm_put; - - ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0, - OV5645_SYSTEM_CTRL0_START); - if (ret < 0) - goto err_rpm_put; - } else { - ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40); - if (ret < 0) - goto stream_off_rpm_put; + if (ret < 0) { + dev_err(ov5645->dev, "could not set mode %dx%d\n", + ov5645->current_mode->width, + ov5645->current_mode->height); + goto err_rpm_put; + } + ret = __v4l2_ctrl_handler_setup(&ov5645->ctrls); + if (ret < 0) { + dev_err(ov5645->dev, "could not sync v4l2 controls\n"); + goto err_rpm_put; + } - ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0, - OV5645_SYSTEM_CTRL0_STOP); + ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x45); + if (ret < 0) + goto err_rpm_put; - goto stream_off_rpm_put; - } + ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0, + OV5645_SYSTEM_CTRL0_START); + if (ret < 0) + goto err_rpm_put; - v4l2_subdev_unlock_state(state); return 0; err_rpm_put: pm_runtime_put_sync(ov5645->dev); return ret; +} + +static int ov5645_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) +{ + struct ov5645 *ov5645 = to_ov5645(sd); + int ret; + + ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40); + if (ret < 0) + goto rpm_put; + + ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0, + OV5645_SYSTEM_CTRL0_STOP); -stream_off_rpm_put: +rpm_put: pm_runtime_mark_last_busy(ov5645->dev); pm_runtime_put_autosuspend(ov5645->dev); - v4l2_subdev_unlock_state(state); + return ret; } static const struct v4l2_subdev_video_ops ov5645_video_ops = { - .s_stream = ov5645_s_stream, + .s_stream = v4l2_subdev_s_stream_helper, }; static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { @@ -996,6 +996,8 @@ static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { .get_fmt = v4l2_subdev_get_fmt, .set_fmt = ov5645_set_format, .get_selection = ov5645_get_selection, + .enable_streams = ov5645_enable_streams, + .disable_streams = ov5645_disable_streams, }; static const struct v4l2_subdev_core_ops ov5645_core_ops = { From patchwork Tue Sep 10 17:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798972 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 AE87C1A76AB; Tue, 10 Sep 2024 17:06:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987992; cv=none; b=dybrK+s2hEJ9MJ8bLE5uOCaYKC0GY1g1R/tQ9vR/2U7ETztf5z+izOUS8S/+RY+LEUHbOpcnz1jk1q9IyongGgVMt+eRoc68vHeZ4PNPM3HLCssV9YOEiZrFXQncksaWCs0243KVmKfWp5UGCY9ic3JsdbMMmAT1ynb+N6dviR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987992; c=relaxed/simple; bh=0mZPOYT9CnGT8QbkXVkiPpzfcUGKMhtdrBapuj7FMRY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lYoZn0ZHV+6jUDRomx7/FJtLNw1LO9mugVj7zKH8c8Y0qhJUaKqbVWPrwdf2+QeYZtb2+qxkQtSjABLusaBLVr7giVAkEQan86UX0oUVAb9K+r6ZTvLTsqGF0oKbZetYUwfHpj/iz/aHV94K4gD4RLvnFH5NAg1eQDjj6ENhKuw= 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=X2NQfYPU; arc=none smtp.client-ip=209.85.128.44 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="X2NQfYPU" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42cbc38a997so100545e9.1; Tue, 10 Sep 2024 10:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987989; x=1726592789; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kSR7Rx/0s8RzKLeThaIHltBgE3HzWfrXkarrelDr1Bc=; b=X2NQfYPUZGBRbFkpNVthIX1HXGVqjbN8GbHbAxDixqcuZR1xQtMkAMzP3xdlvnshSY qQ5WR+sJeZAYZdsVA2a0mJOBcTtPVHP5bd+scD4+kddUQf7No3f2UF3B6oyLHpzJjtRP CLeDFwW/TxaVFkL3JRhjUT7F/s035TagDVmtS8+NtIBj0+iggPGnxXfYvZBiKRk24KBa vQi+rdEH/urv4rzQUMRk6OP/GnSDiO5pKKzDSYSNgM03gqvu02cr7bkOIz7riNF+j5zy 6ggD7dZe/xrojg5cGi4M1HFSbWW7wzQJCQuwdP8sOKVyXaY9tvYJdX6nK4LpqM221fzB AuTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987989; x=1726592789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kSR7Rx/0s8RzKLeThaIHltBgE3HzWfrXkarrelDr1Bc=; b=cWsVxxKSg/6VxOEnk7/x/aWyFORByPJznpKj3i3mNhLlZYeJd0dV54GxOcn5MJSIlh hG2W5kJm/xKBrTeqEvkSYzDn1oPqD+KoTRUm+MeG0jz5g2yN1vlyJKCSo9cwHxwWguIv xMZX1i3dX5528OofRKOOPU3hIPl1VOE56j6tU3EDZNmDa9/kt+htfHcZdiwu5rZI1+wQ EHHHrhVwdqTqSTXFvYp5jb0e6BXCaVmSrEXvPVY78i++RfBVTTj+aIMsSwhYSnhpbs+h GTjkAGlOSGls1aJ84m2RUnB0DY989FRgc0ezGFX7n7Y4onpTrNq9MzRX6Jgo8MEW9u8o Mb0Q== X-Forwarded-Encrypted: i=1; AJvYcCVT36Ql9KPjdEuWSDowd3sWUn8XC95yyZCZ0oZK+KZaSqEx9cEuFcfnUh5a8LE4VryhPf3ABdvnq78ex9Y=@vger.kernel.org, AJvYcCXo7Q0ViEkb12d3AYrqMR/UjIt4eCwtNQxZ8wWP3lxKa8UWLbO9M9nXO6MF/aZKXxJPztPA4I/feEDvsaChN+SpA7w=@vger.kernel.org X-Gm-Message-State: AOJu0YxQXIa0AguRssCGLHuzaJU+msIjVYtyIgE6qjDB0xKEDY1uAZ3n R5xqEIRSF0dNWFWouUnsPKfyALhEfAQjhcJ+CWPGPcP8c1AgGtFq X-Google-Smtp-Source: AGHT+IHbcDhjz9QBvgrn6T144Ta71E9GIWxYruU5UuuDoDTZ6lcr1KbRKvN3srAV7WDbgUOQw73jbw== X-Received: by 2002:a05:600c:1d27:b0:42c:b991:98bc with SMTP id 5b1f17b1804b1-42cbdb822bemr23372895e9.0.1725987988912; Tue, 10 Sep 2024 10:06:28 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:27 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 09/11] media: i2c: ov5645: Add internal image sink pad Date: Tue, 10 Sep 2024 18:06:08 +0100 Message-Id: <20240910170610.226189-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Use the newly added internal pad API to expose the internal configuration of the sensor to userspace in a standard manner. Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 107 +++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 28 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index dc93514608ee..255c6395a268 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -60,6 +60,10 @@ #define OV5645_SDE_SAT_U 0x5583 #define OV5645_SDE_SAT_V 0x5584 +#define OV5645_NATIVE_FORMAT MEDIA_BUS_FMT_SBGGR8_1X8 +#define OV5645_NATIVE_WIDTH 2592 +#define OV5645_NATIVE_HEIGHT 1944 + /* regulator supplies */ static const char * const ov5645_supply_name[] = { "vdddo", /* Digital I/O (1.8V) supply */ @@ -69,6 +73,12 @@ static const char * const ov5645_supply_name[] = { #define OV5645_NUM_SUPPLIES ARRAY_SIZE(ov5645_supply_name) +enum ov5645_pad_ids { + OV5645_PAD_SOURCE, + OV5645_PAD_IMAGE, + OV5645_NUM_PADS, +}; + struct reg_value { u16 reg; u8 val; @@ -87,7 +97,7 @@ struct ov5645 { struct i2c_client *i2c_client; struct device *dev; struct v4l2_subdev sd; - struct media_pad pad; + struct media_pad pads[OV5645_NUM_PADS]; struct v4l2_fwnode_endpoint ep; struct v4l2_rect crop; struct clk *xclk; @@ -826,7 +836,10 @@ static int ov5645_enum_mbus_code(struct v4l2_subdev *sd, if (code->index > 0) return -EINVAL; - code->code = MEDIA_BUS_FMT_UYVY8_1X16; + if (code->pad == OV5645_PAD_IMAGE) + code->code = OV5645_NATIVE_FORMAT; + else + code->code = MEDIA_BUS_FMT_UYVY8_1X16; return 0; } @@ -835,16 +848,24 @@ static int ov5645_enum_frame_size(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_size_enum *fse) { - if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16) - return -EINVAL; - - if (fse->index >= ARRAY_SIZE(ov5645_mode_info_data)) - return -EINVAL; - - fse->min_width = ov5645_mode_info_data[fse->index].width; - fse->max_width = ov5645_mode_info_data[fse->index].width; - fse->min_height = ov5645_mode_info_data[fse->index].height; - fse->max_height = ov5645_mode_info_data[fse->index].height; + if (fse->pad == OV5645_PAD_IMAGE) { + if (fse->code != OV5645_NATIVE_FORMAT || fse->index > 0) + return -EINVAL; + + fse->min_width = OV5645_NATIVE_WIDTH; + fse->max_width = OV5645_NATIVE_WIDTH; + fse->min_height = OV5645_NATIVE_HEIGHT; + fse->max_height = OV5645_NATIVE_HEIGHT; + } else { + if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16 || + fse->index >= ARRAY_SIZE(ov5645_mode_info_data)) + return -EINVAL; + + fse->min_width = ov5645_mode_info_data[fse->index].width; + fse->max_width = ov5645_mode_info_data[fse->index].width; + fse->min_height = ov5645_mode_info_data[fse->index].height; + fse->max_height = ov5645_mode_info_data[fse->index].height; + } return 0; } @@ -855,18 +876,55 @@ static int ov5645_set_format(struct v4l2_subdev *sd, { struct ov5645 *ov5645 = to_ov5645(sd); struct v4l2_mbus_framefmt *__format; + struct v4l2_rect *compose; struct v4l2_rect *__crop; const struct ov5645_mode_info *new_mode; int ret; - __crop = v4l2_subdev_state_get_crop(sd_state, 0); + if (format->pad != OV5645_PAD_SOURCE) + return v4l2_subdev_get_fmt(sd, sd_state, format); + new_mode = v4l2_find_nearest_size(ov5645_mode_info_data, ARRAY_SIZE(ov5645_mode_info_data), width, height, format->format.width, format->format.height); - - __crop->width = new_mode->width; - __crop->height = new_mode->height; + format->format.code = MEDIA_BUS_FMT_UYVY8_1X16; + format->format.width = new_mode->width; + format->format.height = new_mode->height; + format->format.field = V4L2_FIELD_NONE; + format->format.colorspace = V4L2_COLORSPACE_SRGB; + format->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + format->format.quantization = V4L2_QUANTIZATION_DEFAULT; + format->format.xfer_func = V4L2_XFER_FUNC_DEFAULT; + + __format = v4l2_subdev_state_get_format(sd_state, OV5645_PAD_IMAGE); + *__format = format->format; + __format->code = OV5645_NATIVE_FORMAT; + __format->width = OV5645_NATIVE_WIDTH; + __format->height = OV5645_NATIVE_HEIGHT; + + __crop = v4l2_subdev_state_get_crop(sd_state, OV5645_PAD_IMAGE); + __crop->width = format->format.width; + __crop->height = format->format.height; + + /* + * The compose rectangle models binning, its size is the sensor output + * size. + */ + compose = v4l2_subdev_state_get_compose(sd_state, OV5645_PAD_IMAGE); + compose->left = 0; + compose->top = 0; + compose->width = format->format.width; + compose->height = format->format.height; + + __crop = v4l2_subdev_state_get_crop(sd_state, OV5645_PAD_SOURCE); + __crop->left = 0; + __crop->top = 0; + __crop->width = format->format.width; + __crop->height = format->format.height; + + __format = v4l2_subdev_state_get_format(sd_state, OV5645_PAD_SOURCE); + *__format = format->format; if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { ret = __v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock, @@ -882,14 +940,6 @@ static int ov5645_set_format(struct v4l2_subdev *sd, ov5645->current_mode = new_mode; } - __format = v4l2_subdev_state_get_format(sd_state, 0); - __format->width = __crop->width; - __format->height = __crop->height; - __format->code = MEDIA_BUS_FMT_UYVY8_1X16; - __format->field = V4L2_FIELD_NONE; - __format->colorspace = V4L2_COLORSPACE_SRGB; - - format->format = *__format; return 0; } @@ -899,7 +949,7 @@ static int ov5645_init_state(struct v4l2_subdev *subdev, { struct v4l2_subdev_format fmt = { .which = V4L2_SUBDEV_FORMAT_TRY, - .pad = 0, + .pad = OV5645_PAD_SOURCE, .format = { .code = MEDIA_BUS_FMT_UYVY8_1X16, .width = ov5645_mode_info_data[1].width, @@ -919,7 +969,7 @@ static int ov5645_get_selection(struct v4l2_subdev *sd, if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - sel->r = *v4l2_subdev_state_get_crop(sd_state, 0); + sel->r = *v4l2_subdev_state_get_crop(sd_state, sel->pad); return 0; } @@ -1123,11 +1173,12 @@ static int ov5645_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&ov5645->sd, client, &ov5645_subdev_ops); ov5645->sd.internal_ops = &ov5645_internal_ops; ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; - ov5645->pad.flags = MEDIA_PAD_FL_SOURCE; + ov5645->pads[OV5645_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + ov5645->pads[OV5645_PAD_IMAGE].flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL; ov5645->sd.dev = dev; ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); + ret = media_entity_pads_init(&ov5645->sd.entity, ARRAY_SIZE(ov5645->pads), ov5645->pads); if (ret < 0) { dev_err_probe(dev, ret, "could not register media entity\n"); goto free_ctrl; From patchwork Tue Sep 10 17:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798973 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.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 58A9C1A2576; Tue, 10 Sep 2024 17:06:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987994; cv=none; b=r7syf8Di0jx1z6/Abfd6kRBZdsbpO6FNm8f3Fe7kyhlBKbp+CtSjQ3G+9loaqtUtAZXK890o8LY6GAAedwdEGI+6i0VywJJnMOUmMq4vdp6YqN6YdkAzEJTXtVrMp0EQQhsMa2v4Y8B8utC2T2s+x68SCv+6DLer0UXCPTCOMvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987994; c=relaxed/simple; bh=xpySyiky2995dkjsO4rwSjRrg0sLTkvBoK45Yndy5zg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eKXe2ttzvmhFVSArUPVAs/T6HIt4tnnRwpzvrGkyFH4eXVThy1k1UxEMr4mqbVrJQaT7xzhkKrjsirjBeOPMe8qjjz7tlwzA9sdziHRyLCxjcVuh4Do1dIV5BO1FdyaY+sQyG0OoHbynxaAwcJwx2gPqp+/hrBEwAAtl4G23xRo= 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=mpROOnAN; arc=none smtp.client-ip=209.85.221.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="mpROOnAN" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-374bfc395a5so17374f8f.0; Tue, 10 Sep 2024 10:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987990; x=1726592790; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J+YYl4FCwGtLH07u9sfER4tdyIcReIv8G79RB3UU690=; b=mpROOnAN6g5qSFyG/vfrYowloXP9Qeu9mky2VczYfYUfrZB4ifB7/jPE1yH85yfggD 5ccW8UtzpCM+m6j8fLozDlRhyPKa7SumZwhUhmodPucT5lkav37lqXk/DffUQB6DWFFT 8Rt7/SAFfvT2XnO7MT8HuJb5o1SP0Rv9T7DcYOgksoumBChCnJBvMbqTKIDUGxHINGDX kVVH4CLDaMQdlgRGANP12AwdOk5li/XVpe7jERJTISiHCBh8Rr2LKdeiHPEPt+z1Gf31 VeWfQCPhdX1gEtU+aFS9JObOK7yzYYO+3UXbXhe+20CO8XduxJ9wuHtLqKAGSP5EmlPh sbXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987990; x=1726592790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+YYl4FCwGtLH07u9sfER4tdyIcReIv8G79RB3UU690=; b=mq6xbw5XJ0npY0q/qfhJQ6wt4dv3k9HYkk3VUAR60ok3yF7fQOvq9ZXtEaGzZiqBgC tWxC7tp1A3Az1pgnP4Le2RvO+nLcldpbVp4LNKtrV4AMJ8XJxT0nLM2qxWayfWzcGZGZ HYmJEAZwCiqnd5XzXzcBdXDcu/CQlr+X0zMBFo0fFmwXZq9iRjkgzHf5EiFmdtvFQTGH UA/9q+h3M0uQvlUeEF8MK9d5WxfXTPr6vKOI6Eqlsufd7e9MtZyaGfs6tsWBj2lCAJ4o YsPLTiliQxX+JedkXCMr+gNL/4qX/nnSxcbqpjHsWa2TUTNxsq20X0MUTPo+zZWf+c8y ubBw== X-Forwarded-Encrypted: i=1; AJvYcCU7KUvpa05b7fmrxUXyOc6oaSHGXu8Z0iekV3fBhzR1S+TJe7wzrYqboTPoOXl7R2jZbX1pzaR7OFQ7WQ8=@vger.kernel.org, AJvYcCXGi82FCSwzdChgis3CrSL1KfaSaVK8Dc4gGgPO7wr+fafZs9BhobFu+9UwKpBvfjezUaSm9p+CBOEDXYPHqJ20v+U=@vger.kernel.org X-Gm-Message-State: AOJu0Yxvn7LIg5uBWK66OOzzEXqYxJoSYTaeA/GrUr3ub4TyKNXrhvLS J5pzsFwR5x4nNHCmzUqW6SP+j+ePkn1L+CbHMmXGG6U6iasRzbK0 X-Google-Smtp-Source: AGHT+IGx9u+TZbJA6FNFl8Rf0mmy03cHTRfs7nWDZLqL0r0CnC1a5yMXWMsSvYEjpLCqFmvinS2hYg== X-Received: by 2002:a5d:4cc5:0:b0:371:6fc7:d45d with SMTP id ffacd0b85a97d-378a89fd663mr2186929f8f.2.1725987990526; Tue, 10 Sep 2024 10:06:30 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:29 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 10/11] media: i2c: ov5645: Report internal routes to userspace Date: Tue, 10 Sep 2024 18:06:09 +0100 Message-Id: <20240910170610.226189-11-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Usage of internal pads creates a route internal to the subdev, and the V4L2 camera sensor API requires such routes to be reported to userspace. Create the route in the .init_state() operation. Internal routing support requires stream support, so set the V4L2_SUBDEV_FL_HAS_STREAMS flag and switch formats and selection rectangles access from pads to streams. As the route is immutable, there's no need to implement the .set_routing() operation, and we can hardcode the sink and source stream IDs to 0. Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 255c6395a268..7f1133292ffc 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -947,15 +947,36 @@ static int ov5645_set_format(struct v4l2_subdev *sd, static int ov5645_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state) { + struct v4l2_subdev_route routes[1] = { + { + .sink_pad = OV5645_PAD_IMAGE, + .sink_stream = 0, + .source_pad = OV5645_PAD_SOURCE, + .source_stream = 0, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE | + V4L2_SUBDEV_ROUTE_FL_IMMUTABLE, + }, + }; + struct v4l2_subdev_krouting routing = { + .len_routes = ARRAY_SIZE(routes), + .num_routes = ARRAY_SIZE(routes), + .routes = routes, + }; struct v4l2_subdev_format fmt = { .which = V4L2_SUBDEV_FORMAT_TRY, .pad = OV5645_PAD_SOURCE, + .stream = 0, .format = { .code = MEDIA_BUS_FMT_UYVY8_1X16, .width = ov5645_mode_info_data[1].width, .height = ov5645_mode_info_data[1].height, }, }; + int ret; + + ret = v4l2_subdev_set_routing(subdev, sd_state, &routing); + if (ret) + return ret; ov5645_set_format(subdev, sd_state, &fmt); @@ -1172,7 +1193,8 @@ static int ov5645_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&ov5645->sd, client, &ov5645_subdev_ops); ov5645->sd.internal_ops = &ov5645_internal_ops; - ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; + ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS | + V4L2_SUBDEV_FL_STREAMS; ov5645->pads[OV5645_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; ov5645->pads[OV5645_PAD_IMAGE].flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL; ov5645->sd.dev = dev; From patchwork Tue Sep 10 17:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13798974 X-Patchwork-Delegate: kieran@bingham.xyz Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.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 632F61AAE06; Tue, 10 Sep 2024 17:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987995; cv=none; b=s8wItHS1CxyTtOWTy7fUYfQOmgbdntZCRpbJ7DtDvJY5w6wxtfp2A8McvV7pditLgR5TXCq+p00T1UywlkO7x5/x0tEqjR2x4VjtNWnxsphJE+o+rSD1m/izlsfSK3qJzEcSYn8A2qIzDPzgO2KTdBqua9pya6rh9zdDD6pPxPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725987995; c=relaxed/simple; bh=jRrPVVAvrp3Vll+FUIssss1zRjuem5ArSwL4fJny5qA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E78Ymc0iUg1CdMHHEhQjZ2LqousqGorDTGrKszEN4aihVhElKks9i7xtTTBvrDnu4LY4fZ1rbKwjCLz9BYfRXwkMh/JekHY/69/9tIDvedDqlqVbFHXaACC0XUnV5yFnqEqgXL5m+sZRBZG1reOPQb9N0W1NDSyHOgd/WHfa4is= 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=gKnYfYO/; arc=none smtp.client-ip=209.85.128.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="gKnYfYO/" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42cb2191107so23560375e9.1; Tue, 10 Sep 2024 10:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725987992; x=1726592792; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BQMHTCEpp4IX3yk3G5kxDgRhnrTtnfOFN8NLqXpo8sE=; b=gKnYfYO/MG+ZQp6nehF1BZpxRQNJUOuw70QVcNarRSkm9z+Jx0pamak4K5S0VEEwkQ X23Vt/laRFUoQQIcXudo3/2E/AL9/V7aKNUt61NtRHRVMgxrp1WmuH/4RyIDQHb4M50k lcZWH8GBgS9ymsUlXViRKk0sFqHsa0aEuvPi47p7QEKQr/nqOTSih3889OCZ0AEuN/t4 HDb7yOWhJsgfEDXxE+n2hvf26bf+W3D9/IJploCaJNhYqRZiSJsxfIb9aORdQezF8wHa AaOLQq6WA3RGf8/2uQoiD+pMJUTVUlm8u91KoZVdUzeuwhz3QYBmNYmrZ/CXZ7rY7fGH 8Mdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725987992; x=1726592792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BQMHTCEpp4IX3yk3G5kxDgRhnrTtnfOFN8NLqXpo8sE=; b=C38POWei5fVPLzIDyKbB5XzZzYQynROghI+yIGBDvY/sx2hdqxmk0eNwFVfGWULZy4 CkbboUXqiQ8BdH0iardN8xkdN2JpxGdEXWUDZdDNlM7oWUSgyTrTMo3rmWMWyE/wcUl2 GmNmS++CtfjfBfUmDKDtUIFiFiN+30jTJdo0enrTGoVhwSUcprozWCmRjoDoM3jsU6qE fQMNOKJIh//ckac9oDNzo/gf/pgDbJuo8eTpemRP0grnAz0xgY3lYSlIeDCl8k5jRGJX Cszg4EUHKJ2EkwB+rKA90vqjGULTcgyc5k9b94AIS8/qr4N0e9rlqCy2sL+O63WA/snM h2qg== X-Forwarded-Encrypted: i=1; AJvYcCXBWp7mWPzKpsKTHoHBO25HBUQZFG41kmX/dVIv2QNOBDot+Mi9TPwSHe35B2Dww1g/wwuv/6KuukZL2b7BNwAujko=@vger.kernel.org, AJvYcCXiM5kWAT4ROVA8DWJapNsjPh8jnzFNNm61Q23euf0U7COW62+TA5fkAe0E+FUjWlIZQdSUQChvI5fIEvw=@vger.kernel.org X-Gm-Message-State: AOJu0YxmeN921co0NlmPd0GGb5T8nswc+o9BCC2n6hA1APfjoFWehzZm cQ1SneCiKinMKlNPfVwAU2tda1qB+ZDu8sD64mjFkr23cLpfSVlp X-Google-Smtp-Source: AGHT+IHCIAWbw+eAm5SROvYzPz1sWj9QkYeDiWGz2IuG8TYLQTwbpr1D/Zpp4M/M+FsBjtFTiU82Ng== X-Received: by 2002:adf:fc91:0:b0:374:c432:4971 with SMTP id ffacd0b85a97d-3789268e9a0mr7381931f8f.16.1725987991762; Tue, 10 Sep 2024 10:06:31 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:94a6:1e64:e5a2:2b2a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956de4b9sm9438925f8f.111.2024.09.10.10.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 10:06:31 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 11/11] media: i2c: ov5645: Report streams using frame descriptors Date: Tue, 10 Sep 2024 18:06:10 +0100 Message-Id: <20240910170610.226189-12-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240910170610.226189-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Implement the .get_frame_desc() subdev operation to report information about streams to the connected CSI-2 receiver. This is required to let the CSI-2 receiver driver know about virtual channels and data types for each stream. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov5645.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 7f1133292ffc..c24eb6e7a7b5 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -829,6 +830,32 @@ static const struct v4l2_ctrl_ops ov5645_ctrl_ops = { .s_ctrl = ov5645_s_ctrl, }; +static int ov5645_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + const struct v4l2_mbus_framefmt *fmt; + struct v4l2_subdev_state *state; + + if (pad != OV5645_PAD_SOURCE) + return -EINVAL; + + state = v4l2_subdev_lock_and_get_active_state(sd); + fmt = v4l2_subdev_state_get_format(state, OV5645_PAD_SOURCE, 0); + v4l2_subdev_unlock_state(state); + + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + fd->num_entries = 1; + + memset(fd->entry, 0, sizeof(fd->entry)); + + fd->entry[0].pixelcode = fmt->code; + fd->entry[0].stream = 0; + fd->entry[0].bus.csi2.vc = 0; + fd->entry[0].bus.csi2.dt = MIPI_CSI2_DT_YUV422_8B; + + return 0; +} + static int ov5645_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -1062,6 +1089,7 @@ static const struct v4l2_subdev_video_ops ov5645_video_ops = { }; static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { + .get_frame_desc = ov5645_get_frame_desc, .enum_mbus_code = ov5645_enum_mbus_code, .enum_frame_size = ov5645_enum_frame_size, .get_fmt = v4l2_subdev_get_fmt,