From patchwork Wed Sep 4 21:07: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: 13791452 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 5D1881487E3; Wed, 4 Sep 2024 21:07:45 +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=1725484066; cv=none; b=JeXMIn3x3hSdIM26XoEyZBD89UX8VBV6rrtH3ZqdZ/QdidwFYYqloctgUybKVMW/1CcY5VOdoX6/sXhK5ixg6ritLvl30OUW3pM5AaedBGIebnfFIjTrY10u7hj88/Mm9A+AZ3FQF+A/Tr1uyQN2M/QnIQMOXspP7ISKq1pDKrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484066; c=relaxed/simple; bh=aY/aJQpV38qNROExL3xJqYKRw9fwpPUOQxSrGJ5yIiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mhqSJxoR+vEaQKDneJRTSIS84x9fIE8GtSWJy9wbEz7dtcd81diHavKAGAZB6p7dXjwMEUETKfKJQ6Hw599Z6mPfnZFejhql4IuDyy9HRGQ1NFTZA1SZ10Fxa7eFelhDiUcQkbpjXU21KKfDZ4LsO1zBmNQVFyKcOPKp6V/p8aI= 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=feEMuDac; 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="feEMuDac" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-428e0d184b4so57861845e9.2; Wed, 04 Sep 2024 14:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484064; x=1726088864; 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=feEMuDacp5/8AVwS/GD6natgn8NT90d0yTyx4OxDEePK4QojkrpiSpeudkMuHi/VKP I+WWtMV/oGg/u5oOxzPbpaD3AIrFwJwLl8KMoeosc5TvhhEBcioUd6/fNghA5bqL+SID Ot7WqXAPxdLBDhMrTI1AzGyW2qbiC6IJmupTVxdSw5zoEC2ren7u5PW+gyBk6zPHuKSY 6lfw6VoulZh50AjAg6H0EqbDZnSpt5XT3Hvk5nK17tKrcgyF0xbawSRzbDsVkdl0bjZ1 aSuhB7GiMD90Cu98b8Cyy4Q8OwE9flgw3f/+0y94eFZGMY5DE6Mu5VczAnEpblPM063E 2cBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484064; x=1726088864; 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=Xw62PWbgRqD/xfzsz1v6RwBOUay2kGuebqzJlV9HSaBBf9cNyjcavYEd9yy7l1UrmP IVOtBt7fjZ2eFJSy8VOi6eh0rugGwtR9G7NSIC/SEOnkRDU6z3dUbBH5E9NuSNkdJp5u Q4PQbmAIfu2g7bzikTF1cF/k5yphG2CogpIbAmB2PiQbzBfHvma/eG86n5uhMdujIqrv Ah8iU65GrLrGjAOhW6wu9HIHOLixQGnWye4g+bGULG1ETdMq+ECcwqb73o0Z4MzA7XBm cQWXeKAUzS98vM3oWG1qAOBiuByGftFVowP3OssGmKAvRTvNw2sm7i3Elp1sNtzBns8m TPBw== X-Forwarded-Encrypted: i=1; AJvYcCVyRnwSUBNStIZxe2h+yIl7Dwn64dQtkuRIwEteKBkp0Ga4FgmM5aSHh996WaEq3s2kP7Uk3gOBBGX4SDU=@vger.kernel.org, AJvYcCW2+6dh/I8DgM3aSOJo3NXAtzh7gNxRZ9Qb2wVClKC+kFHfQlhWFrCWYmaYSZd2krwABXJcHKZk/YmhELZx0TcxBUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzFNiT5ZcO3RKf52dOBI9rAnmoae8+U66SHYmBTmHhmNaW72b/z giQPmo1iWxyvPYcIkaLFXN/LU959p0oOASACVHzt/b08GQrbMVXU X-Google-Smtp-Source: AGHT+IEG1xxnHICBbjgQjyLAhdPkSCuL0iFOVc2UlPBgzSYVPheCM3ApQ1pzzl5GKWc09JGokwSXJg== X-Received: by 2002:a05:600c:3b8f:b0:426:6320:226a with SMTP id 5b1f17b1804b1-42c7b5a8f75mr113452075e9.15.1725484063692; Wed, 04 Sep 2024 14:07:43 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:42 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 01/12] media: i2c: ov5645: Add V4L2_SUBDEV_FL_HAS_EVENTS and subscribe hooks Date: Wed, 4 Sep 2024 22:07:08 +0100 Message-Id: <20240904210719.52466-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 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 --- 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 Wed Sep 4 21:07: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: 13791453 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.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 D88C014EC60; Wed, 4 Sep 2024 21:07:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484068; cv=none; b=d68WpYu3+cYIheSWBgib3E1FIIxBgnY2q1XumQ9nuPkh3e1U9BX8lOTMt8L69laYilpWIeS1DKTmvG6+SiTWnUmfWdG4YngsUBroofVZQHQbDG/dqVypOI8pmxfgwDeU4fYEWR9SfJV4KMyPH0L3h6T9wyacTZEvAe/tFpOt2ME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484068; c=relaxed/simple; bh=JGdJLaovjJBbYCO4/ZAujBbI9fa+eu1eoBgflmmamM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nFfhf/p2V2gleuYSIh5GXQqQzW4IxRQFsid4XsWzNcdn8UeIOaElwAuLCx2/B4oWELAIFi8PcXFfbJgt7X3ZZ6PrdqGA+oj/IueOSsl6E6qxo167XOIF5iPc5D1Dvky0yumLy/ry8vFWe9esNJn3OdHyoJvVxY1DOGH8+DOYuGs= 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=WuR0DZqs; arc=none smtp.client-ip=209.85.128.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="WuR0DZqs" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-428e0d18666so59124545e9.3; Wed, 04 Sep 2024 14:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484065; x=1726088865; 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=WuR0DZqstu/k8DnBSpEFoRyIr22HQVOLnqP2BkLGbeLbMY/9RvxVsKrxa2wEo2ie0F u4RF0UhxnDx3/RqeI5Bo+0j9XzfuhevKuLwcjFDbfajOjY6pvm+7iFtkIkAqbYRRgebG 3SRuJo9b0V+uD53S/C79AMkCCyBCRspoNHkO6kbY3Em9If6j1mWJFduJw109TjLxLaeL /jDIdFvE7wYiVxTqmiBXO7aMRbBxSZzywM5y+WHipr+MOPLebN0t3MxlIwjUbolEfUzb FvBhJ/v2L+3AwpcgbMDV+151QG+cMq8JbwlouJ3ztm8DrCKgV984CCL61dZBmYi61XQ2 AgVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484065; x=1726088865; 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=tnIw1X7BwXuDlp+52V9RF3dxX5831JAl6d+v2Bb6SqanFR3PWNJ3PbxNAunsGOMGJt 5bGDcICCS0nfjdZQnm8lfVw913vZm8PVLjXwAq4ds4hJHCS7ncrKiZxVsYNXhZ0Or9YW KJUQyS8issMajNydPrihsCiL174wUcf8/7UmlYt/9/ft36P6U4bfF8ZBOVC8aTOUC4p0 jPNF76TvH0/uKrwWj4AueRZnVsItw76uYhjtsTSPI8IRGUx+6xa/AtNFEBzYh1Kdxx8b aTd4Dwp5uvGvvNZITov3gOtS15/5qfzw9jpoQRpB20H+TAlBQ+IYKpAqlk1kJN2M7++F n51Q== X-Forwarded-Encrypted: i=1; AJvYcCWCbh2bk6yO31kDCfClX54917z7WAMWUcBuUmWUZGNjm/RmDhPzIWX5h6IRNqfXmbd5ZyXdT+ZZHCNLfdM=@vger.kernel.org, AJvYcCXum7xAh0HHQZ2Cxm5hggLmjUsjo9BZ4heH6vbM7Gj+vKA9mLBuDOFaI2PC8Kj0X1hgJt7VCWBD1yks40sqi6YfGKQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwXCxQsWHM8fWu732k34JbnBzf88v7VH5xwMGK1+tEZUHgtsCMa p4rySdxQAbWDafZeLpRgUdMcR7VMYZ+x0At190xT3AaTR6WteWq6 X-Google-Smtp-Source: AGHT+IEJEdlvZiZejf9Ym+pUkIiUf7OIMvZfRqGYvcm6nl9i/Uhhz+CPD+JFbg4H1U6opl7Ha3W+gw== X-Received: by 2002:a5d:68d1:0:b0:374:cb30:b9b3 with SMTP id ffacd0b85a97d-374cb30bbe9mr7356400f8f.2.1725484064838; Wed, 04 Sep 2024 14:07:44 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:44 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 02/12] media: i2c: ov5645: Use local `dev` pointer for subdev device assignment Date: Wed, 4 Sep 2024 22:07:09 +0100 Message-Id: <20240904210719.52466-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 --- 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 Wed Sep 4 21:07: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: 13791454 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.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 31953155730; Wed, 4 Sep 2024 21:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484069; cv=none; b=irId6KVbMHZNErwX764JpCSfs0jnCDOgLQKM/qZlImLgofhGG8dnf1+dFGE//I6afLrteryo2IZOjBsOAXxBtebNAl73xn8xGsW7zhIR1YHzIIeey5FmHCk/O2eXMGLmXlguWkQ0qmNZf4daRgk0WpvE3kbSpWaQ+FaRMtmceZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484069; c=relaxed/simple; bh=ZShCPWFSW/sqGfuamWtEEwCfgDxJvKsb2CpN+xf6TmM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qnDjbg4bH6eTVJ5DQNX7oB3rldJaR2nGeKJA95k8inw/L6oaQwhW/qg0NRhSRZxiz7q2bl/iZDqW3HCRrwgppHsm5CuXjdj2uUXOuJdzYUQl+trd7XxEGLDiiIeKILrMuaQo+ZE6UhpVwGJwrI5vvIB+9MnAqGPIezrclqkQd9I= 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=SKEh1Qwj; arc=none smtp.client-ip=209.85.128.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="SKEh1Qwj" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-42bbdf7f860so49602505e9.3; Wed, 04 Sep 2024 14:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484066; x=1726088866; 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=SKEh1QwjrNZB0EgB4tcnkGE5+9061I8DgEkkBZgAyRduODZNwxwuqTVoqPZOlVWVdi WU1A1ZpVoh4K5D1BiCg/MZEYwTuoWwZCafQzVn0I3F3I4penkJtiLdZSeXhVXV8e0Eff YncmKFKvnl7QvCsyDVCXFZYwwbAkMU+rX5bFU2vq8d+kx9+vYpC6NSWFO24VLIkJC9vO AxpnXe5N5pMHK0ku6U1vpyWD40BSsthuyRXifRcujnUJWpdh6mXI6OsBYO4ekX4GE7+V nyNOrwcM9Byg2XdyUpTbiLDsmxUxDRCGti55EBmBQjX+Hlqln58w5dFleLs9h8LYLwUH HIIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484066; x=1726088866; 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=AB+ex+poePJrLb1RTasUQ68xATd1RyIFDWhuCP3y8dioXiJybXuSBtXfagRZDLv8mQ otozLLPBeo+rKtas+u/ROmjfgPO3BypBEj0oI1vtzYLHt6cy9DWItsacM1KLIEKxJymm grLdkuPgDEpbym8CpVzzbMEYtANbVwje9eI9H3+OA0AFGdXKP5ERUHmPY27EY/6vWCkl LnWSxZCpZqyyXqApwzlMu7i8EJ4J/oc6Lzd/5r74d5B2q1vavugk/ptFvpb8TimfYebo wmRLmggLmza1R5IYMrUVFnl8WN8SbfiI/JMHGUk1Laxd1bjnLNnS0HwnND8HWpKX35I7 cyew== X-Forwarded-Encrypted: i=1; AJvYcCUQ8aq7QPqAmPI1b5nXx0bSP1PtwBjJbamD32DbYBopnzbHafCNBOGsPMYGZNqg6PRYvlqEY9kqfDBljtRyDzbyWSw=@vger.kernel.org, AJvYcCXxMQ1hHZE7WSbHh0+AxURNZoSNTvlW88mxnwqwPd4AkBYbQDUUy0QZR36GItXzm1pl/aYcPz9//Ijhpc8=@vger.kernel.org X-Gm-Message-State: AOJu0YyZCziY1EWihUMP9I88oGUZOQEPQAF02MRUySaxXEjKybmYOUWK zzWgDYkZQHnqH1QQ5kgUfYwQpRx87ILrXfbm5kQaYZxK356F/jHBD4TvqN5Y X-Google-Smtp-Source: AGHT+IEoXSP87wrRFdk7Ds9PuCqQ6FnuJW8gUgmKIEgIap4lxBZMxsuTOXKY/agSUQrCywIB2nz3Hw== X-Received: by 2002:a05:600c:1c83:b0:426:5440:8541 with SMTP id 5b1f17b1804b1-42bb01e5f83mr160393635e9.27.1725484066515; Wed, 04 Sep 2024 14:07:46 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:45 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 03/12] media: i2c: ov5645: Enable runtime PM after v4l2_async_register_subdev() Date: Wed, 4 Sep 2024 22:07:10 +0100 Message-Id: <20240904210719.52466-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 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 Wed Sep 4 21:07:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791455 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 8E01916F839; Wed, 4 Sep 2024 21:07:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484071; cv=none; b=HvbkALoWuEU1Xd4VItwuGt54DIks/5p/xyJC5SGQXai3a4E7cHD1DD2R3tGftj/Dy3T1LG8FBav36R6Vb2NtaVbcH6WUGY9jzhZA1WqIEOQz7AR9sEycNd0mr6o0VgETKweZCFvTySoJF/xbpQOqQaSuPK/ZHSE5ES7alv+QjcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484071; c=relaxed/simple; bh=Zx3pVc2b4AnAFqjVntb6HlOm0c6VIoOxfvWt+DeZo3o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kx9OJN7QDC5pkdSlq/39itmDbrvebs7UccvtTQfwlQZE0P96GxG9yZBw47yh7iWOxpxTfrFAgYZpIhTXGGgYUJ0qk0Tb9FFqwJHwGgaVgiSev6dB17q/QZXe0zW5XgCM0liEo47WuaQwAzYem5PD2TM14Q+6Y2kbugDGpZoPCL0= 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=YbohhZ1r; arc=none smtp.client-ip=209.85.128.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="YbohhZ1r" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42c7856ed66so39626555e9.3; Wed, 04 Sep 2024 14:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484068; x=1726088868; 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=YbohhZ1rr9CeANvE8D3oMDJJHZqcZMAu7ESoLX6ydDM8DmKGYNSjr3zZft74B7dh02 Y3PVUJXqLQkPEYU//+pLMpy2dfkaaS7PlGF0kL3kaA39aEKfPneMOsBLwPxfUu1cEZ03 tep1zQ8mBB0+8Qr6lg+oQ5gbmhTLFJoq4W+ADPTCscMWSGL6YCeOpuA7bo0CXoywiOk6 a9YIOLHO96f235G2oNNgcsav9vYLmkcXAnrRsTYf8V7y//jGpnSecWxVFATagiFha5/2 eIgak5P8cAXoM5erkz5vi7RZ99rmghncmREmUVZlE3+LHOJ7YDiTPmnH/dB/AiHZZAKA UHqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484068; x=1726088868; 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=bX3MVInWV0dLltCtRnRBL4phBS8i5QGJwtZ5Xt2fQjm0FWJw07xDGIxot7Sm8lu019 H3WEsTztl9oxJN5BOiEx/aN7ClI8twDMdRBVRzm1xxwzcCG/y7RiFXAp9zjwvjxqujPI poDDR/yoebUhED/DE0vRhDl+Q60MgewaRHuZ4OxxdWaUrbBVtNw0VZbpmmTpaDJd5XKU 5mdf6tLJDDfiYV7r1BzMocJFSYR3nDt9EBfDFeGobAydkE7uHg4lVsl2/IdxdCYEgYBb cp25/PaR1FSCipWUv7W0GiKWRsWrgfp1EEfnmAO7y3LOEae8oycQjaRfgG2Ki1Hn+1JQ ptJQ== X-Forwarded-Encrypted: i=1; AJvYcCV0pt+Tmhj4xCXM/mDozodbJQYUs+uTbN2zw68LrdkhsePmOzuJIUrdCyQ8Y8OBA+Z6Bu4XrkzmAi9A06A=@vger.kernel.org, AJvYcCVuX/quDrn5awgI1i3ISmfzBya2hEwGQB3z2m4ml8pGK/c8qfQjBYDt+6TJSy5HrXEJlQFBssFnEbQ5q9yWfMJdOvc=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv+xGQ8Ya4UfDdBnZV8Vw/z3pRtkn3bnra65gwEX3I5S76SZlb oS3PsPrLkyhOhdtxcTmCxxCihzohiGrzpKWhtsZ3bs0qYBeaSRfH X-Google-Smtp-Source: AGHT+IHx1plvaNYUp7UTL7Mk4GJERbS7EP/coTqNDtFuvopxMzHj3TstBPxHvkbwbgLbXXjqiWKFeg== X-Received: by 2002:a05:600c:4685:b0:428:150e:4f13 with SMTP id 5b1f17b1804b1-42bb27bc4cbmr146300705e9.33.1725484067747; Wed, 04 Sep 2024 14:07:47 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:47 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 04/12] media: i2c: ov5645: Use dev_err_probe instead of dev_err Date: Wed, 4 Sep 2024 22:07:11 +0100 Message-Id: <20240904210719.52466-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 Wed Sep 4 21:07:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791456 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 8245517ADE3; Wed, 4 Sep 2024 21:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484072; cv=none; b=sNfZ6z4HEELwcYp6a8IyxTi+7IIw4iCVrgnTeJzitqe85wgilrdRqc5MYci8sLk4TVUL0TbPVbwwob1EeszQULhdzl+7KlBGqgCO525Vm7NtYUGvLe30HdhwcNIqYGBmvCfMoWUMu3pk2gEP2mNEXPUJEpRjE94zxK+YTWoXC8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484072; c=relaxed/simple; bh=Kiv17uNGthDImT4AMacEgbQWK5UrKLL4azvkUaL16aU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cc7oa+06S6f9V5ylA2FOxPxYIgpGAEUPzS1v3hDSDQFOj0V/1btzt1BPHPxBCO13BrMi/VNRbQQpAb54wGNXfFT4ZWPF2pBjZK80gyvbPUn1pybCgY1hN3EKRC/8yn4qPxWGm1zZ0YdY3ogEV5KN07aB4Z55zsytlNLjze0ZIqc= 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=jwiWTeu/; arc=none smtp.client-ip=209.85.128.47 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="jwiWTeu/" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42c7a384b18so38409315e9.0; Wed, 04 Sep 2024 14:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484069; x=1726088869; 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=jwiWTeu//CaIkc2E0PoXRakN+zvI52qVnwz4Bhwuqsfg1jMWWOLkNPo5n/82Cq4sje XPmwf9VGty05HZ+tpkY7rXaU2oySB4+M1eIEnbqrlKfQz+2WxK/CExMMC5cnTHa6ml2F u7CoKmNWLqyodP9AggOXOBNq+SemasTFgHVId4TObfIDUxb4T4RspFOCuOM9VTJpq7Bd wVfC33AT320atjueAWFKz6QzRLRKyF0gzmw75YKpaH/W5NWulbqur2CuzUmoMf5hyOTr fmfcAdPOPV52R8gy1I/0ZETIvyTiI3P1nGos6Obi2L+Tqz3/v0Xa/Jex0Ijh8mOsAdto mKYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484069; x=1726088869; 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=aSkCfsGFA02N0LzlVPflBRbhBhy/4vBxwdVPEaVBhoyx/h56D9oJoxtEgaobfd6V+N 92TLEYOqUQ1t0fJv3THo9lUPolVFmw034dPPTSxhFXP2YJ4V8B3aewh7SZstRlDXAhiX P9HqDu2nJVpdqi+lTFEnAZX5wuuXsdAWUPdbXWlmMn8mymuJ/vLdKlPpiMhfGg+8iDOr cq2i2oMZhnuW0ogA5/UhWoWCkofg8xH0RH9HgMd2QHpaNGiT1VSfzdP6RNqHf3QPht7O mD3SRl9xzYd54PtF+28oj4bCOcgMmKl2b+NI0k2QqVRE1d0xITzOM2SId3E7HnXhvsPO 66NQ== X-Forwarded-Encrypted: i=1; AJvYcCW4v4vllz/5GaOrg0rHkWVa5cd/px9WhYhIInq1rKLf9Ji2y4lit2OclnxMGJScBPDTDA5zaZFqdk3eJYarV+dxb7I=@vger.kernel.org, AJvYcCXhC+BVgZjJhBVzuXFcCvY1H3GlC2onU/zhtxZnQXGD+6ZEr9kDRQDsTZkef7fjgdZIlpSdKoML8hoth1o=@vger.kernel.org X-Gm-Message-State: AOJu0YxmpLIkrT7ZxHrhUK8P67a5O+Q+Wasmy/r7w2C2aq83o4VOmTaC voZcOH3OY0FFQ4d/cyyKs5fSF3iegKG4us2anaum2ZwcP+Yqp/ye X-Google-Smtp-Source: AGHT+IFfoLmN74tHSM1gS2e0hyRY3c4mok1G+mSB4+mlKuPUEVTrGwadMKpokwpNQfXY+mm+ZgMGkA== X-Received: by 2002:a05:600c:3146:b0:428:16a0:1c3f with SMTP id 5b1f17b1804b1-42be48faa09mr124645185e9.32.1725484068909; Wed, 04 Sep 2024 14:07:48 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:48 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 05/12] media: i2c: ov5645: Use v4l2_async_register_subdev_sensor() Date: Wed, 4 Sep 2024 22:07:12 +0100 Message-Id: <20240904210719.52466-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 Make use v4l2_async_register_subdev_sensor() helper to register the subdev. Signed-off-by: Lad Prabhakar --- 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 Wed Sep 4 21:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791457 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 8FFE917D8A6; Wed, 4 Sep 2024 21:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484073; cv=none; b=RE6rZswOD86hdcbqDVb0BLShQlObZczkm9vgDWP0O0a3UcSfT8u+uzzh9QbvWf0cbZYtIrGrGWfnA7FaKRnnTr6lpW6XBo5muuKClJXE7evUNb3/s8urJntjSentRelQT772ZKm1DYdvOu0Ndh4GnBkNBFwZYK+O2hIA13tyuUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484073; c=relaxed/simple; bh=mAqO79O3l/OvTSDmMNjmx02R4NEoM9pQ3zCM/ZFlJSg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lSADhIXxl3sxr9/O8LzPvma5zgXZi842a3KxZy6aX5SH0UH0bFdbZ6l779Ifckye9uE/u2FPw0xEPevGb7n4V6Y6hkKsBwPgaKBFJBncishnT6uu6FTDc5NpYgYCtMbOxep1vYqJWe5Bi6oGLxeFQ+zqAhvtPPn9CW9j8BfyJYU= 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=AexVnjM7; arc=none smtp.client-ip=209.85.128.48 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="AexVnjM7" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42c79deb7c4so38336085e9.3; Wed, 04 Sep 2024 14:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484070; x=1726088870; 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=AexVnjM7nCGVVzpwKnIfxSJ/ArLkdGcPc6AHHH0W62d93ITsstbPmDLkWATOwBZydG zwG7zw17W3wCcekH+oZrH5qanN3+Dl3F9haVtnISpGwnfAH1vR6esQEfLRN+7li265Xc mSSj1SCDbcB4AVdXyXVBePfFkcZZtDim+W+LFBhF+bI47Dzjrw2OZm/rfWz6l+P8zqvj ds2Py5/FX+1BUOgkMn3s8qwiZKnscfQHhaqtJg21pqqi1zoktmr+ueSjsFv4JFasbuul dk7feEHW1FWrQ9YEy9+sDJyq28iGO9/AaE4ydBj0szCXqLCGHkdx+cTmvpyWCVpLKuLT N4qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484070; x=1726088870; 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=uGY0sFc0mkj67ZgsFCW0vYtz7j4kNvmUmRv0w9Qty1pRr91O2oufWwb5DsPbykh7e8 9jL1vkKUFwG9IDxIbFK+R8RukCePX/c+XlOhEmvQq2Y2ychJRfiyJNHcnYwL2piyzALV 8q0zNZRnuTj+cUkkjhOhO2XjSza+9oTomjw+cl9MS+wYWk2YtLN5bI3K3GbSayMMXEgc W3/Qg4Oca9QmME5YWEcs5yVyqU0LZVCfU1VbdnL1yTQek/lVITzjMTZZFBtcTiqZXTEi nwa6r11RcE4qPMdXwkshHK86Fc+1vAvTdt05FER2Eu7jIBA2MSWV3FlPoUI4gLgy6mdV uUdw== X-Forwarded-Encrypted: i=1; AJvYcCVyZUOnpZyzQfwjRwZO7KEJr9TZAX0l8ilt3V5XdAa7QK1amM2RyBPRaI+XkcKIg4SadmfiRhCNO20EO4gXLHNyEiw=@vger.kernel.org, AJvYcCXMNRVxRiCh1j/+T05F+vcyr25jOPuCTHQf2ic46d954lUp3TEnTfLFa/Px0/XlIf2b5mf/pFYcaLQxeio=@vger.kernel.org X-Gm-Message-State: AOJu0YxkP+Y/UOKr9uRa+RjNTFmYhccET6Vuvhps5JUw597AaEIpykZL Yi3JZmOvRb6AAKWXCGHYTPXFIMfMPbHygopNpxm8FGAu1vHU1kBV X-Google-Smtp-Source: AGHT+IFnV/SeymYrLZnIp7dDYpEEy8cLjhEhsc8/peer0h3tQKe72voH7q46naIO52wikLgYpiGV1g== X-Received: by 2002:a05:600c:3511:b0:426:6f1e:ce93 with SMTP id 5b1f17b1804b1-42c7b5f0e91mr93465055e9.33.1725484069973; Wed, 04 Sep 2024 14:07:49 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:49 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 06/12] media: i2c: ov5645: Drop `power_lock` mutex Date: Wed, 4 Sep 2024 22:07:13 +0100 Message-Id: <20240904210719.52466-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 --- 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 Wed Sep 4 21:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791458 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.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 C14A5186E40; Wed, 4 Sep 2024 21:07:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484074; cv=none; b=t0Mw8nHrutiT353ovHZaWH6dmFpSfH92PJ4pgGLFBMAQej4YvVBCoYNWCAKTEWzNM+Ws7aXlfGyqpqG1598gv6gwK1iz/OWAfdscYgAbq7rpzjJtyjcwkdVHY2rcLumxtz8KMQvczEEo1Vn6xYg1BvAMX/hRdFCG/eGhJgOJfJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484074; c=relaxed/simple; bh=Ht70IJcyQJH4Dhqjjac98yUwsL35MwaRODP3k/kTeYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y4LwBMrJe1U2W8CAgjRrVCSUt/yMFNRuxL1tnFp5UfrIV9mo87jtm5wMGYAYUZunhzz8WdKRTXjX5+U6L3RACzm+kqQgufeho4aUSiRri3v/1c4YRydrazmNhI1iwEEsmNde7eTSrXnijBtkGXJhpB+eGNUg8WS7Iv9T54/Wnu0= 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=hEagMnYG; arc=none smtp.client-ip=209.85.128.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="hEagMnYG" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-42bbe809b06so45963025e9.1; Wed, 04 Sep 2024 14:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484071; x=1726088871; 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=hEagMnYGr5GhEsirkwQSLmXCHOSmMvFWmivbhnHxgtkAgOLXnh7bWt8udcnj5rZS1W 9xb7QJHWuYbk6G3GlEtw4vuqCbJCkUzVLGDQpuwN6Y7DRwsGbSJxCW6cUifX2xg+HWew A+xs/DfkgSNkhJtSDCfblbvuBVSsl0V7EcsBrSze3Il1tQcGg9Y2+jOSHXvch8AaNh9P M4Dn3GQREaT36XUFbZO6mNIe6Mdlb64fAIHVUKePUBNcoaabfEM6Baydk86UO6nX7dud 880/ZSFtjEezs0Ph66HAudLor+/IiMnL3fn9z7B8Sv16dujSsfuLoHPujcrhf6qL+zHD qb9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484071; x=1726088871; 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=B+Y1P0ST0sqSlQiV95WqjeLj+5qf08JGttiUDaX3ocdwc7i9LbufJ8sUtgihloBxqk rBTix7JZfp8yyOvZcsJFCHmWkHqllwFQK+LtNwVAWcNuIRHqw97HGYECxnkkM/P6o4T1 OsN7PMLtmsJXlutrbLHV17tqQVv1JggpavktuWkYswkX2KoACyTNO2rzli/KnYaRwD/b xvJMqYi7qspfZnfJaQXnHaxEIZtGziCK0FJ7KaiVf3VhUqdvLzu6KqcAcN5ANI3MuvqF 3dq/eca8T1+XRVBGHB+ArZve/6Olz7vMPa8dQjhx02pMuvs2E7t4w2+FNedzRSNbPu7P nAhA== X-Forwarded-Encrypted: i=1; AJvYcCUcyJD74lr8Guf2xedrGInCdeO6rxmOu1WCkKpET/cgCketfqjiGXpQ5cBGVyadvu/UguFwO5epC8I0GVeMPam0rSQ=@vger.kernel.org, AJvYcCVJUMFcW8iEc6I/t6hznm71INtb5lOd1yHQOgZBxohRASzkCb089dEbEyuCEEyInDsGsjFnEEklhDuZbFY=@vger.kernel.org X-Gm-Message-State: AOJu0YzVxbLlGydM/zcJtBaIXIa06buleKJshiPSD/0OxrvRg2DOQ4kl XC/hDOJTI6iBhsL9xPVH+3EEk4YEePqiz8pYivPT2LaDqWQ/Ll5eEg8PxYWF X-Google-Smtp-Source: AGHT+IEZS+UfmS3KPR+czSjHyVOuYwvsavbrVZc1vnhF2nnFXsx2e4lTetlRGuvsmV1PL1vuTZaNog== X-Received: by 2002:a05:600c:a07:b0:427:abed:3602 with SMTP id 5b1f17b1804b1-42bb27a9e95mr155931335e9.24.1725484071106; Wed, 04 Sep 2024 14:07:51 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:50 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 07/12] media: i2c: ov5645: Use subdev active state Date: Wed, 4 Sep 2024 22:07:14 +0100 Message-Id: <20240904210719.52466-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 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 --- 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 Wed Sep 4 21:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791459 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 1C95818891F; Wed, 4 Sep 2024 21:07:53 +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=1725484075; cv=none; b=K2vN2gZllW80ALzKEd+eYssFReMrRWfpie77g0z6KOyz7STO9lqkos0wrmhmEgzU4IrFy5KjsLoti4yek6yvzK62NiesX5+PgZEktgXFRljhC2rliKV6kYP5O+mLNZWHKhUWy469XnrLnaFhcg08kRXbxmWsbZrdhWA6ddpwayw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484075; c=relaxed/simple; bh=TlPMS9+iyWeF7BUutFeeBinJP2I92tXInMXqr1sU1PQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qCAFFYQVM03ZRczdM0xQefVRD69+cbFQyTwzzz+wAGxB8R7M/Ai04dy1MD83ctzvcGdiHULK+Fn+ZsQLLJco4pHyiOu7nofyIQvYn6vx1mNEsKwC2CIKAwJEOd+FPdFgtxKrhFmU8JGzYXf/yYLn6Z/eRUudcLURw6MGOHLOyNE= 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=XfCssyf2; 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="XfCssyf2" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-428e0d18666so59125475e9.3; Wed, 04 Sep 2024 14:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484072; x=1726088872; 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=XfCssyf2TO8cwyaktdfTt74OU8NbRtFxhh8grV+ykvT/d5EC7zLtmnu6xLXPf87b1j DUWfS3oPR9Sgj/7pIMuFKFeK8vpRFcBnwSLqZa45m5WEqPNqg95y8f05KpIvzMtApaSD wPKkcYWTrlPAaGgBo2FXtyP/2jqWICO8z+ggQQRsyERDKa2IzpwGxVnWkJIDmfk4l82c J2MqLGNRzTqYK7pMxNEYmyTOEORIwjQsXzzvRxPD079C/DZcdHQECd4hmWPDLF6NT/3U 8j9CjO4X/xor6TuOzJmm+CrXxJdDvJUDKGpNb1f6Ik1Yp6fgNDv5LhPMMzzZA1R5zPua M9ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484072; x=1726088872; 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=oddOCuCAKnmAPON64YEiQd3x9MBwmoJ7Nsyk/XApz4ex3sbF94ZXLWmakglGfDdf9/ WM4DfMtjbMCEMi6cgyoOQ6VNXK+xsQBXqVcuM5CfXuNMIzjjzC7Dtvchj6IuYvhqWesG igAIBvIaoZ3CVTvtRtZ7wnn1J8TN1dkHP2vw3p/ES4hlWqi3Kj5p2wmB/h4PtZPrrLf1 u3+pLnp33wUe4T84PlpEmsD1/ZCGZWs0H873hgEwcrpLAmyOjrQa0Ji2P7gYJjXgy8Ml UkW8CXjWtX1mjTitxxGLrzy+UqSbdUouc6A3e0zkQ+CMloj+V2Iu6HihUWUx8DG2fifO jUcA== X-Forwarded-Encrypted: i=1; AJvYcCWeGdYLDdrIgpaVl0rHQOXF9tqBuVuBBfQs9kEdC0Qj5iJ6buoI/T77ZkhEeCKe4R6pYOhBVPsImZbqZE8=@vger.kernel.org, AJvYcCXqEGhD5e0hCqvmYyvjgFAt9wSrV8Far1vhJ/qUW7OPvkl0O8gJsypowgNbnIdZvWJ0lhbywVs7BhXgo2u6kPE5WdQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyQaDJOnj4/jZpKHKxjimnSS9vgXyhb/8Yxu/tTp7Pr2z0i19y7 u50BDfrMbIzAibC8OV8ddGVCCZXuQ5XBFNqYeq90Ah2He9zeQ/6HXPIv+RxZ X-Google-Smtp-Source: AGHT+IHZpCwBbgsqrX1K5IUcdMqJRqZMpH3d48/SJE6eA2d4GRAAcTDTJ4yIh/wf4xey6BdUT8qqmw== X-Received: by 2002:a5d:59a2:0:b0:374:c42f:bac1 with SMTP id ffacd0b85a97d-374c42fbc87mr10363182f8f.8.1725484072428; Wed, 04 Sep 2024 14:07:52 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:51 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 08/12] media: i2c: ov5645: Switch to {enable,disable}_streams Date: Wed, 4 Sep 2024 22:07:15 +0100 Message-Id: <20240904210719.52466-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 --- 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 Wed Sep 4 21:07:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791460 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66B25188A2C; Wed, 4 Sep 2024 21:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484077; cv=none; b=ZvWH1j5IOB1e+34E0z7F/8Rzane759jbM4LHzk5+XDVWHBSq/WKxpcqRfuz3/VE4dwr1Rz26dAGaAcz9w4kVZz3hYqBDMHWc72/Ac3qTT2FxHvAQyiHZ/wLeFxu1rV5DIttFX0AXo3kUeLAWGTgl/oY9HFZ5YcMpADmItBjVUgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484077; c=relaxed/simple; bh=apy/83bf7I4kNRjoOT7IzBaFlyBQwcddIcj61s/vSOk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ksp4+gisodqP5AYIChqE0ldMS3DkWa8Bre4grbNkkZ0cvXMxTm749s7yTbzEn5KvnhZADrPgEAO0UZMgeQ4NYdBQBtCcUj0HS/52AqRg/Zv9t1EDKWyFP5YT8S8Pnju4ST5Ar0Liya+24VyJ+GCEi0i5uasiYN2XfAfFhow4QZE= 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=liuYzK5m; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="liuYzK5m" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42bb81e795bso57365495e9.1; Wed, 04 Sep 2024 14:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484074; x=1726088874; 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=yOjJvonRGcQ+cw3Caitccalck6hyNMNmMbmy0DeHlz0=; b=liuYzK5mAdhVd5kX6MpA5zss6gYpAMvwpd7VRwGDWb4NKT6r2yT4xL4yEEWsU7Cium 3v7+a28Gf+nqgk9USkHe2x1Hosba9cfDOh7LnQc07YIPMdh57qU24qVMRgQXL+ekavkx ZrTKay6PQO/nFH8ZRaQpHCImpajpIcCcEJPkpWgr2Emyd4WL1aTDUIwzPLte7xUKzbvz X9TeNqmbmV1s3hFMElCe/ZqlRSwqwd/jy7dczvSFEp3vVOwh3FXDkitKFV+ACTTYqiWg Ko6Sv0t3d7MR9uT/N6+tI4lzBx0TIU+jBbyNB0WShTuLBQycwFaCdZWGPLhuuvox0PNf AFDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484074; x=1726088874; 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=yOjJvonRGcQ+cw3Caitccalck6hyNMNmMbmy0DeHlz0=; b=HeLSb1T9jHiabUi2UBbAYIWKB9tqijbOQqqHKJZ87OWaNzmPKpZmLWb8JzS3ZXf6HF YSCaP+qHF7IhkGBLWcLGOEl/kUJ1WSSMHa4grN55a6wDwSL+JlBV+y4awu/gEnLArTqd sVOUDFsurJHOx/Mysw+6GQoyBfAcDbfn0xxRDrGzrBQpInqzCWQUApP0y762OZAEjmsa x8LljYE7eqYNdB/ZlLh6COd6oQdoCb+ZQsvI7dZfOxfHGWO8IHpVS+TKVW+g7dS1yL6x eZgujCz76vV7HYgjHCWwIMuCbWp6e5VaRgVLaHJL3/By5KmdAljSzUkyHBaJ+C+zUjHD upNA== X-Forwarded-Encrypted: i=1; AJvYcCVwXT8fvOeOOK2d0j0zYc6njzn144gjDpSpC19dWVdJ57iERmeQ4Yql8QM4Mcm2xFVq+RGRvZBrRShXYdWwxxIdC4A=@vger.kernel.org, AJvYcCWo9zdJAPJekn9CnkLDhCHeoM/w0D8SJH1Ocu7vj7Q5WP6AlqkHbcGIyislyppuaHo9GFwM/uPHQ6IuRS0=@vger.kernel.org X-Gm-Message-State: AOJu0YxCUvoyNJwaC9Ah9b8hLmZ3dyXiFLoFost8x1+rpMUiSbBJSISH e0L9QWg3B+lKiPoAGtNFA6/FoxjAm/rxI31a2mjZeDqmrb8HxQ0SNUHcospu X-Google-Smtp-Source: AGHT+IH97t1XBKFiU1zdF2evTW8Pdo2F9taSRES/a0mu/hIDdp0cpPpzDpvb6YqT5ng0+pLMF2l48A== X-Received: by 2002:a05:600c:138e:b0:428:c0a:27ea with SMTP id 5b1f17b1804b1-42bbb205ac6mr134731205e9.12.1725484073747; Wed, 04 Sep 2024 14:07:53 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:52 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 09/12] media: i2c: ov5645: Add internal image sink pad Date: Wed, 4 Sep 2024 22:07:16 +0100 Message-Id: <20240904210719.52466-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 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 | 100 +++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index dc93514608ee..e5ec09f44bec 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_UYVY8_1X16 +#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; @@ -838,13 +848,23 @@ static int ov5645_enum_frame_size(struct v4l2_subdev *subdev, 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->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->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 +875,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 +939,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,9 +948,9 @@ 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, + .code = OV5645_NATIVE_FORMAT, .width = ov5645_mode_info_data[1].width, .height = ov5645_mode_info_data[1].height, }, @@ -919,7 +968,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 +1172,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 Wed Sep 4 21:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791461 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 C40F51898E1; Wed, 4 Sep 2024 21:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484078; cv=none; b=rrvmE9fZ0OogMNtj5mrj/0q0NggzGbtrX0iNGIboW7ZeGgF8Z7yx4UvnSXhrEAovdPaueoDHbeHsz9Jqeecj4++ixbi++X38MqdSN9YYma5RjFycdEOSkLXucD1Lx87ky2DZ04MWH8MxfxPjPhgOVTCCf6kazc3sV3uw7UfTtr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484078; c=relaxed/simple; bh=jzqa1ut+5yUIkNvgtui45igFbPcbvGJIFbgoFI8N6I8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kkqo6mzD/JvrOm5t/cpG5KaAlfSrtFvROgSuiJud1NU7r0NnGWS1Kjsf7OLdQvuDvF2kJS9nlUuqd7E0O3FMtGpRnclrlUA8hdKAzNRzqmX1KwD/kms+sI4hGtqHJWdI+LDtSULshxxajh+vSWy7MqgG6aDDohRwG7saT2P7Nzk= 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=RDlvPoiB; arc=none smtp.client-ip=209.85.221.41 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="RDlvPoiB" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-374c7d14191so626907f8f.0; Wed, 04 Sep 2024 14:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484075; x=1726088875; 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=W1J+9XNW4CsktFOBdcl6+iRK30VsMjMiAHF06kCLm/c=; b=RDlvPoiB8NFoxgUG+sXVEB2RHhWR9HyEQFJdTJTVRigiQZdNN057ZWpBStLUv5DG4j 4HPrA93PyniW3YeDb+MyDcQk0Ggatny8ZpL1wdcRYtVUwBY+r051wfMzToqLw6/rQZhU M7ZfMWxqFAjNpP6G90T62yj/aLoKzorR7N3cWsXXQ7Iw22wGNo8n8kdRRD2eGe8ohv8M LhRWl94KbMfOb87c4AjfX1DtHTY9WWPRtANBBmEdOL3zKYKC0d7uHYw89Oy9T/wyyGZS NMUYsNW98a4kXb3aDR9dc5p7j6EsciZUd6VezHLBnOJBvSsw9Z/OBkb+8m6lo5owP47K 04FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484075; x=1726088875; 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=W1J+9XNW4CsktFOBdcl6+iRK30VsMjMiAHF06kCLm/c=; b=aZc45+KrEsx46tAkQ5N2Jq3fDRXbi6SArd5Hg1eI/XspiGnwV3hVDXnG0/cWDO1KtN PwH6n1SCtGpl0zQo4cdWfH0Fu9cP9EHNVewNlUegcPvk5BSPFVeWv1o76pt4H3uiEX1m x2mZKIviYdR4bM2j1J1JpIFundzhSjE31VdOPMzA4yUgovR4zVxY6fa54y4FUV6OFIDC j3qP/W6/B1lZbYzRBuS032fQOljznTa7tvTqeESmQ5m9G57P6KZpWM3lZ0hKpofCJN4n q6mkA6qD2biCE6Xx8GfD8m4yai2LhWf4SpB2xVHWZ7gTehv47TKt7vZ+yvPhPVDCJhGd RQwA== X-Forwarded-Encrypted: i=1; AJvYcCUiNaUyltQXl3EsU2AX8CcZvCRWxb8bPsN2ZawIQWA2ja+e6GZsIvB7VnAXEFdoV8S8Z/mFCOArecCr2LtmL9qVQDM=@vger.kernel.org, AJvYcCXhTfP0h9mzb8uwhcugoAvSyS0wpkHZViM2DhwHRlYCf8qjoV0i6sxYhucxLqbB04Pi4mKyaBhmXNpOvh0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywbtc9/6RMtTVQQEwI7leZMOzv+gW0gTAZ/7krq+y2bc7ctfZxd Jr+G/e5hUkEbjLzjjtX8BcG18HB6TZ/TKHi3kjIiMXuYWLqNLkLK X-Google-Smtp-Source: AGHT+IHe6AWWYqF3gje9YHnl2a+KBa7nOScIeRb4YrwPuWv0nYHsf4e0s4gIziOsm8JaK3EvXV0ypA== X-Received: by 2002:adf:e882:0:b0:374:cc89:174b with SMTP id ffacd0b85a97d-377998aafc7mr2294272f8f.4.1725484074900; Wed, 04 Sep 2024 14:07:54 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:54 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 10/12] media: i2c: ov5645: Report internal routes to userspace Date: Wed, 4 Sep 2024 22:07:17 +0100 Message-Id: <20240904210719.52466-11-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 e5ec09f44bec..14010d328e79 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -946,15 +946,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 = OV5645_NATIVE_FORMAT, .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); @@ -1171,7 +1192,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 Wed Sep 4 21:07:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791462 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.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 ACF5D18A6B0; Wed, 4 Sep 2024 21:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484079; cv=none; b=g1abEJe8WBksvnoGXIrnuSZuGfoPvfv6ReQVD5fmkmW7f5SCBPhSQKjRf4jJypDxXANGUGZAOrFF5w9eWefre0uCVcU+ZStxV9jfPeQfIXKwrymzz5wdqNyQvY6kVEI5fjiSCnXQ89YoncD8DDiQVge44DfjjUJpxY9/lXI1c0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484079; c=relaxed/simple; bh=0j/GEeuxLu4HcIR1VojcZGXjpw+NsfuHifXNqadlWm0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WVsStfZWPc6KzRaZUa1+eCvqKi652pZ9WZWIeBQemNPUK2zoahaKHDyZ5qSnpMQep4JSJ+tFZmyeIZZWTmKsqEfGCJ/1LRRIqG08cqLCIIanvGNk2V+3o8s7JacOjYwW2bZZ67hfRuYuv4Vw+637V773AuXx/pLkfj7BSAkamco= 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=VT1CbOC4; arc=none smtp.client-ip=209.85.128.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="VT1CbOC4" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-42c79deb7c4so38336455e9.3; Wed, 04 Sep 2024 14:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484076; x=1726088876; 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=GkG2UKqmGGAU2ZlTW5zJdnvjcvNezmRv0bTbQ21OpnA=; b=VT1CbOC4Jfuxoiv0UtDJu5MMn5izBQmBZasnFBp1lNHiCwBaqqclG+yO81JseOnb/G xRBIjWoQjLl4LRWLy4miXdP33hFmLARgtFZOtcYM9H6szj/rqpyE5y6P998e8JlxKtST 5nOHxMqDOrA/7XkfusK/k6A12r1g58e6FxczxTAnOQs6oLEP1KhHYe8uJRIE35QH5u8S CjA3gqaD2/dqdfpi1lGRZ3YSTrYl/p7XnUlQulwDLhAC2BnjsFYwr/roVzcCRrOLs2nT TFOlMSkMFiVCIeolnmpnTBUSNO0rd3tyN3Y7gj5rtY9HllxfeIv15c7eIum99E9zXY/4 2RhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484076; x=1726088876; 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=GkG2UKqmGGAU2ZlTW5zJdnvjcvNezmRv0bTbQ21OpnA=; b=gD+/1BaUzLQ03jKscQfIjBJFWFP1xkfE7jFfNwC/x5qszU85Xc8yBLv2tsOp0yW0YJ ZZZww9VAt1AuW1kDTjJ+bTBWe3ahJ03roWe9RDx4GZQJ1S9qaKW2crLd6EM2O99bzH0a w9bRqXj/bz41tKVL4rDXGDWmqbUrQ7eSP9p55rYHtzrvBmUHzvhnfa4b/yi5muOe27Ek vY3XQE3ywHtC7JjxC6A3MyT4tl+DWlsgBIdvOHASUZG1pUyQo5x14+41beEE/sjlvxNV rjhgugnr/trNvLiaZdVQai2hBmqLkIX9WkvhSIoXm8uE00PUEOzOOl6cKrut2I7ERtkP YfVQ== X-Forwarded-Encrypted: i=1; AJvYcCUzLEDZq9m8VEu3rq1ZziEsO4FF9mAkapyBT3MEVao2m2N2vWK0TMLmOQufkm7jRUFNU09LVf59Lon+XwA=@vger.kernel.org, AJvYcCXVjWVFfRAy6sgf7Nwu8F/746Z6elQ8YpAljsGoMuNtl0XScVf6G98LVnrxOQf4h2lHHPEik8d2IAjbv6CT0rsCPlQ=@vger.kernel.org X-Gm-Message-State: AOJu0YywJEMahVcgAhpylYfUnS0iqNQ0nTZ3tM1wg6l2VZS5acwwSpFt aq9/aSNerlNEkWjnYpsE6IUep5hIzLX9LPkAY5jQqC25cVMknrzT X-Google-Smtp-Source: AGHT+IHmQ8DXYWFTgFm8T4pyrIKvxkeZTrDyn2eWsUQJ7y/Ei26juDuXm8eqUcnMxTZA5qtguLTW9w== X-Received: by 2002:a05:600c:3582:b0:42b:9260:235f with SMTP id 5b1f17b1804b1-42c7b5b4b72mr93342855e9.19.1725484076041; Wed, 04 Sep 2024 14:07:56 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:55 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 11/12] media: i2c: ov5645: Report streams using frame descriptors Date: Wed, 4 Sep 2024 22:07:18 +0100 Message-Id: <20240904210719.52466-12-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 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 --- 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 14010d328e79..45762783a19f 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) @@ -1061,6 +1088,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, From patchwork Wed Sep 4 21:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13791463 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 303BE18D626; Wed, 4 Sep 2024 21:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484081; cv=none; b=iB2Z7CZUnYWTDm+zf/YBi/rgf9EfWDCzbU/xb1rjCSCDlgsikkCA0sYIVjZKDpMlG/5ZrXo5xB96HFllzfKjjR/zgiwBLazqUU85ev0gPUfA8Af17F7lDENJDL45K/1ueGhGz5cFFhw8Gck6YeuqwLa6TlFjtC5VL1UKQI+ccgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725484081; c=relaxed/simple; bh=I1oNs25s/CngsnNqJwET5V0cEjBj+iPLAzdWDG9ZV40=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KHec8vjxu/KdOaSi7e2CqgN7B936zyXncEydi/J6OajMEzD8p8xlmeku+aO2kRzghMSgH+AGTaKHJK7LRetJwCuwdgwqW29LDkiS2f2cv9FZD+Y8JGbgQnPLkQosDBQ67WDIoEFEFUyWkt4JzrNaVx+ND6hAv99b5vBDOanfgA0= 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=jQ94xGpr; arc=none smtp.client-ip=209.85.221.47 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="jQ94xGpr" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-374b25263a3so6930f8f.0; Wed, 04 Sep 2024 14:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484077; x=1726088877; 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=J426v0t4e1crMfA9lHahgdUfXyTzbtJSjN0almmRPYQ=; b=jQ94xGprnb/4py5/WOqGSlV8MQkF0y9s0n5HtrpdGZk73TqR3O1VqzXPPoOUVR1xQB gq2O6iKVd8AL5yRa5sCcoAHhNL+xZyHF+stR3IRoy903aO9zQC+IkJnXd0rhpfAUf2v4 oty2e8y0jCQQx9SIH2PeFL5GFMEn3QEbYmeclJ7EbyCo6E+P+ZJhmxez4OAw3z/FeKih cZ7pkbQom4I5asGwfhe3ILvbKX4rwW+/loITgkG4EwhpbZm8i5liXt7PvEs46+rNuHsO ab+hxIqnpFVY1Qvt6k71suirBckRVjcKwtYj5a1GA1t3x10T6qXQlseub8pNHzIy+RDH dlsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484077; x=1726088877; 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=J426v0t4e1crMfA9lHahgdUfXyTzbtJSjN0almmRPYQ=; b=SVPqu2KzmAjVBPxzt5Y4jHpLBw6BHdd4omc0pd93zoPEVV6D9LeP84iJ14SdLu0+3X pgo95ZgsZmI3H8dZpis3wtnMF88uudZG6lpU7pGDA/pR92bMxX0mAMdXuPyfDC6sTIIy cHNRaKdbK0HkKn65li8EWXJ6kQt/UbLlqTGYR0iWgCBJ6Hafrp3d68eCcSwiAxSqaoNX NT1fb/QTGRYModhBneaspodPMKCf0JzJJzXYNw74fpWmQMbv9IH4ajTvrwH4fxff8csb ZcZYekxElufZUG0zU7XXTbLDrRRgxHEu/pd8+n4zp2pEwkHJCDQM1mqXdGMSKRrXkvFm wTbA== X-Forwarded-Encrypted: i=1; AJvYcCWypNMsgHxBZqD6Imi6hfhm1XMrXHBMxOsljpe4L104RxVfcsU2n2DADH2MhLXN9Y08/jzdSDL9Wjkc1AtOra6Kir4=@vger.kernel.org, AJvYcCXDIYZ4bLGPuFXTtbxsWu/vubn0R6e3a2d+Vx+PjdbJwbwFPz70oVTAmrNHT5JXBnRVD6fQX2A4AV8n1Y8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3tCIMPCuwsVhQvdD78cW8b0qmusuLzLoi7BUbB9/djFsjCLZp YsLFKde515OqYajNiPq00tK97QJwxOoYDrIoc6aoBsIdq3/Tvw1T X-Google-Smtp-Source: AGHT+IE1GiKVJANdTHXMQYX5WVnza6IY/8YZs4CwJfcbTEBsVHiBMrT8Bto4Xkk/dF2CvYe3e2Pzog== X-Received: by 2002:a05:6000:137a:b0:374:c1f5:affe with SMTP id ffacd0b85a97d-374c1f5b5ebmr9419683f8f.40.1725484077459; Wed, 04 Sep 2024 14:07:57 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:c57c:1e61:792:2ab1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c7a41bdc8sm158821485e9.3.2024.09.04.14.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 14:07:56 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Kieran Bingham , Tomi Valkeinen , Jacopo Mondi , Mauro Carvalho Chehab 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: [RFC PATCH 12/12] media: i2c: ov5645: Add virtual channel support Date: Wed, 4 Sep 2024 22:07:19 +0100 Message-Id: <20240904210719.52466-13-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904210719.52466-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240904210719.52466-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 Add routes to configure the virtual channels. Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 153 ++++++++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 37 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 45762783a19f..cf4a6d8e83e0 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -54,6 +54,7 @@ #define OV5645_TIMING_TC_REG21 0x3821 #define OV5645_SENSOR_MIRROR BIT(1) #define OV5645_MIPI_CTRL00 0x4800 +#define OV5645_REG_DEBUG_MODE 0x4814 #define OV5645_PRE_ISP_TEST_SETTING_1 0x503d #define OV5645_TEST_PATTERN_MASK 0x3 #define OV5645_SET_TEST_PATTERN(x) ((x) & OV5645_TEST_PATTERN_MASK) @@ -65,6 +66,8 @@ #define OV5645_NATIVE_WIDTH 2592 #define OV5645_NATIVE_HEIGHT 1944 +#define OV5645_ROUTES_MAX 4 + /* regulator supplies */ static const char * const ov5645_supply_name[] = { "vdddo", /* Digital I/O (1.8V) supply */ @@ -833,25 +836,36 @@ static const struct v4l2_ctrl_ops ov5645_ctrl_ops = { 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; + struct v4l2_subdev_route *route; + unsigned int num_routes = 0; 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; + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *entry; + const struct v4l2_mbus_framefmt *fmt; + + fmt = v4l2_subdev_state_get_format(state, route->source_pad, + route->source_stream); + + entry = &fd->entry[num_routes]; + entry->stream = num_routes; + entry->pixelcode = fmt->code; - memset(fd->entry, 0, sizeof(fd->entry)); + entry->bus.csi2.vc = route->source_stream; + entry->bus.csi2.dt = MIPI_CSI2_DT_YUV422_8B; - 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; + num_routes++; + } + + fd->num_entries = num_routes; + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + + v4l2_subdev_unlock_state(state); return 0; } @@ -923,13 +937,13 @@ static int ov5645_set_format(struct v4l2_subdev *sd, 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 = v4l2_subdev_state_get_format(sd_state, OV5645_PAD_IMAGE, 0); *__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 = v4l2_subdev_state_get_crop(sd_state, OV5645_PAD_IMAGE, 0); __crop->width = format->format.width; __crop->height = format->format.height; @@ -937,19 +951,19 @@ static int ov5645_set_format(struct v4l2_subdev *sd, * The compose rectangle models binning, its size is the sensor output * size. */ - compose = v4l2_subdev_state_get_compose(sd_state, OV5645_PAD_IMAGE); + compose = v4l2_subdev_state_get_compose(sd_state, OV5645_PAD_IMAGE, 0); 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 = v4l2_subdev_state_get_crop(sd_state, OV5645_PAD_SOURCE, format->stream); __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 = v4l2_subdev_state_get_format(sd_state, OV5645_PAD_SOURCE, format->stream); *__format = format->format; if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { @@ -970,43 +984,80 @@ static int ov5645_set_format(struct v4l2_subdev *sd, return 0; } -static int ov5645_init_state(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *sd_state) +static int ov5645_apply_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) { - 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 = OV5645_NATIVE_FORMAT, .width = ov5645_mode_info_data[1].width, .height = ov5645_mode_info_data[1].height, }, }; + struct v4l2_subdev_route *route; int ret; - ret = v4l2_subdev_set_routing(subdev, sd_state, &routing); + if (routing->num_routes > 1) + routing->num_routes = 1; + + route = &routing->routes[0]; + + if (route->sink_stream > 0 || route->source_stream > 3) + return -EINVAL; + + ret = v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); if (ret) return ret; - ov5645_set_format(subdev, sd_state, &fmt); + ret = v4l2_subdev_set_routing(sd, state, routing); + if (ret) + return ret; - return 0; + fmt.stream = route->source_stream; + return ov5645_set_format(sd, state, &fmt); +} + +static int ov5645_init_state(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_subdev_route routes[OV5645_ROUTES_MAX] = { + { + .sink_pad = OV5645_PAD_IMAGE, + .sink_stream = 0, + .source_pad = OV5645_PAD_SOURCE, + .source_stream = 0, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, + { + .sink_pad = OV5645_PAD_IMAGE, + .sink_stream = 0, + .source_pad = OV5645_PAD_SOURCE, + .source_stream = 1, + }, + { + .sink_pad = OV5645_PAD_IMAGE, + .sink_stream = 0, + .source_pad = OV5645_PAD_SOURCE, + .source_stream = 2, + }, + { + .sink_pad = OV5645_PAD_IMAGE, + .sink_stream = 0, + .source_pad = OV5645_PAD_SOURCE, + .source_stream = 3, + }, + }; + struct v4l2_subdev_krouting routing = { + .len_routes = ARRAY_SIZE(routes), + .num_routes = ARRAY_SIZE(routes), + .routes = routes, + }; + + return ov5645_apply_routing(subdev, sd_state, &routing); } static int ov5645_get_selection(struct v4l2_subdev *sd, @@ -1016,14 +1067,29 @@ 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, sel->pad); + sel->r = *v4l2_subdev_state_get_crop(sd_state, sel->pad, sel->stream); return 0; } +static int ov5645_set_virtual_channel(struct ov5645 *ov5645, u8 channel) +{ + int ret; + u8 val; + + ret = ov5645_read_reg(ov5645, OV5645_REG_DEBUG_MODE, &val); + if (ret) + return ret; + val &= ~(3 << 6); + val |= (channel << 6); + + return ov5645_write_reg(ov5645, OV5645_REG_DEBUG_MODE, val); +} + static int ov5645_enable_streams(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, u32 pad, u64 streams_mask) { + struct v4l2_subdev_route *route = &state->routing.routes[0]; struct ov5645 *ov5645 = to_ov5645(sd); int ret; @@ -1031,6 +1097,10 @@ static int ov5645_enable_streams(struct v4l2_subdev *sd, if (ret < 0) return ret; + ret = ov5645_set_virtual_channel(ov5645, route->source_stream); + if (ret) + goto err_rpm_put; + ret = ov5645_set_register_array(ov5645, ov5645->current_mode->data, ov5645->current_mode->data_size); @@ -1083,6 +1153,14 @@ static int ov5645_disable_streams(struct v4l2_subdev *sd, return ret; } +static int ov5645_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + return ov5645_apply_routing(sd, state, routing); +} + static const struct v4l2_subdev_video_ops ov5645_video_ops = { .s_stream = v4l2_subdev_s_stream_helper, }; @@ -1096,6 +1174,7 @@ static const struct v4l2_subdev_pad_ops ov5645_subdev_pad_ops = { .get_selection = ov5645_get_selection, .enable_streams = ov5645_enable_streams, .disable_streams = ov5645_disable_streams, + .set_routing = ov5645_set_routing, }; static const struct v4l2_subdev_core_ops ov5645_core_ops = {