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: 827253 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-media@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: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: 827252 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-media@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: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: 827251 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-media@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: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: 827250 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-media@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: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: 827249 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-media@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;