From patchwork Fri Sep 6 17:39:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13794486 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 EB2B1154BF5; Fri, 6 Sep 2024 17:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644428; cv=none; b=jzrDn6GfHDGoM5Ue5gm1QUoS9L3z9K4gJ2ntJkctyphN83PqO/z+vB98hhdeV6qPyaES/CUxje6IbRUk5YLpOWhRYs1Labyd8jOYNFxETqpr6nz82qlhhUaNtXMyYHXQ1jfECe5kEBHT0l5k+eoX317SAQ1XhEwjFeehRMcWWoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644428; c=relaxed/simple; bh=YPKrvoiTq6nWtkxe4ZFFcGAZ8SFTIBuM8+heVE/TslY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kviFiijU1p9DAr6Fn/bKsl0RLxlXfsmhaobTFFcgsrx/2nG4RRKbASqiII5TnmFHpmIEZzx/S9cs9glYQTYA3ap5t1+S/4aNBWz+yu6/1qvju5AcYlIMOLaZbAlP27UcYoAsmKzW0nCSOKWpMTlrx0R6Ku03aAJQPsaySp3kisE= 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=m0w+Rrzx; arc=none smtp.client-ip=209.85.208.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="m0w+Rrzx" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5c241feb80dso6520617a12.0; Fri, 06 Sep 2024 10:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725644425; x=1726249225; 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=leNcJ9uVUwRxDumIwXcMwTGBOKocFKMYGNyhiFfYTBs=; b=m0w+RrzxQnGtIuwMDN7b4yFkKduynelcTrp9p2vWyZBm/g0mkYgx7PHioLs8Ew5yVq 9D2gUYg8U8iaiibYiqAbXp/Ur+8wQTKQMo3qMCnayKV4rhvPK4FdkfhPPwNHDdHkcAGU ZqUsNIZb7waOJ3XnnI+oRzqZ5HnDrui3RY+Jw3OiQ8pk+NavHulw/EVu9SZ/fh75uO4z GgZtox6VIwJ/8Vz9NdQ6fTg9AWrozmVanlSTagewyaaDV0aqtkAeSpdHfE+dMIfNbiAc WJf8fgicip/PiqdosthGholzeDVPRirHCFDWHmvCUPUEmZ3tjJN26xniF2utNVrtY1lN zotA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725644425; x=1726249225; 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=leNcJ9uVUwRxDumIwXcMwTGBOKocFKMYGNyhiFfYTBs=; b=q8DZ/+rEILZwcq/ZQbdQyWmDJ//iw6F3yopHZsY8XvWrUoUduv1DrofFLcKE/eAHqx MKXwbAZD4a0M5UHERqaqX6qOnT/lMhCXSQFIBvjKM3ia+nggoLjMoFIdtRYEBpPyiShi UocOozAOtybHuqrlPe6v3M+G57Y0Jl8z4MUSLMIhWjYYx/Mv2ZoPgX2vzhrIV2K9hHq1 Z5fmknh7anG0muMnChtOX3m3c9MsChwDkp5YEmulH+SB/Bx2cQtDn7/buxttu8zzi0vh gZ2b2MMMeTxW/S1YP/QAreyKNt3Lwk1i/HQYKGXUKQvv+JQ3sSHpHnDJkq3fJ/e3A7AF LHvA== X-Forwarded-Encrypted: i=1; AJvYcCV/7lcRwHs8SJyZdWyLfhhQ/iqavDvs7uecodDlDBHGhT2x4PhoFujhnN12dsXwODpa2CQ3i5VEuFgKXa0=@vger.kernel.org, AJvYcCXt6Yp6BKi4rwMk2VpGbVaB66oSgHw8KBMoOtiX17dDttb2tBaLxZdsgtKZwrEjHU8FAI2UpRLWPATFPsTG1gELLN0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2QI8Zt7baGFph3sIOl4ScwhmQGX+3vym5QsDbY0BzOYYBxs+n VR/WwrfcztbFhWn0ADz87zb8wOFl1CV+OBiKeliIuP1FlXfpGqK8 X-Google-Smtp-Source: AGHT+IGYAW1HB66qZRT+Z/jqAkHuOohLiBmqaWAqGxc7uAydfKGIjNVf2raSiK0zdl19BYJd69V7SQ== X-Received: by 2002:a05:6402:50d4:b0:5c2:e888:4cf4 with SMTP id 4fb4d7f45d1cf-5c3b291c3b5mr11076727a12.0.1725644424929; Fri, 06 Sep 2024 10:40:24 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:2595:4364:d152:dff3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3cc697fedsm2623557a12.64.2024.09.06.10.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:40:24 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 1/3] media: platform: rzg2l-cru: rzg2l-csi2: Implement .get_frame_desc() Date: Fri, 6 Sep 2024 18:39:45 +0100 Message-Id: <20240906173947.282402-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906173947.282402-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240906173947.282402-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 RZ/G2L CRU requires information about which VCx to process data from, among the four available VCs. To obtain this information, the .get_frame_desc() routine is implemented. This routine, in turn, calls .get_frame_desc() on the remote sensor connected to the CSI2 bridge. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- .../media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c index c7fdee347ac8..a7e4a0c109da 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c @@ -582,6 +582,17 @@ static int rzg2l_csi2_enum_frame_size(struct v4l2_subdev *sd, return 0; } +static int rzg2l_csi2_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct rzg2l_csi2 *csi2 = sd_to_csi2(sd); + + if (!csi2->remote_source) + return -EINVAL; + + return v4l2_subdev_call(csi2->remote_source, pad, get_frame_desc, pad, fd); +} + static const struct v4l2_subdev_video_ops rzg2l_csi2_video_ops = { .s_stream = rzg2l_csi2_s_stream, .pre_streamon = rzg2l_csi2_pre_streamon, @@ -593,6 +604,7 @@ static const struct v4l2_subdev_pad_ops rzg2l_csi2_pad_ops = { .enum_frame_size = rzg2l_csi2_enum_frame_size, .set_fmt = rzg2l_csi2_set_format, .get_fmt = v4l2_subdev_get_fmt, + .get_frame_desc = rzg2l_csi2_get_frame_desc, }; static const struct v4l2_subdev_ops rzg2l_csi2_subdev_ops = { From patchwork Fri Sep 6 17:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13794487 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.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 496FC1C7B68; Fri, 6 Sep 2024 17:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644428; cv=none; b=YDXQLYKbahaTcZEQxbnB4hXqGuV4P+UPl+6NsFz6cwQEwp9R4M6QGmUG6oFG45jsJ4rGkRRKeGhWt4AeemyTogzSNJJHFWesb9i9IcuNqqw/AbWStqr6o+1QPmEcnWXdMV7la3DeaYTurUnDSGJs9BtNvGxlU4GFkDm6GnacWC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644428; c=relaxed/simple; bh=J1D08QP3JWZC9EPGqmGFwOWwTT046231QJ//mMazpms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QuhA62iPoYvyO6g+0P3ZNUiY05JEu63eSjWF32q1D2T+3OrFpPhZi88/XBmgMYCxqvuBnYwzVNSPutspY7+GsWuqkLGycuAqYc916sVWthEulVggcpnzjiuC9U/4E9KRHOdE5a/mARZsdmd4QJPDTe7CQehrfUOYlW54+mfe5QU= 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=S8j6CAp0; arc=none smtp.client-ip=209.85.208.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="S8j6CAp0" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5c3d209da98so3323611a12.1; Fri, 06 Sep 2024 10:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725644426; x=1726249226; 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=N4LxwlnlL6G3NSnwOnhswZ56WZ0hWrrgxscofAMV3pQ=; b=S8j6CAp0FnkIYrsGqj0n3F82UEE/+ZPS5ixkKH2AemC/ctTHtmxjnhrvnQoWOSuwII 4cI0MJIwBOM8ST818DzuggX/Q/QMAYeh3PbJZN/UEc4ZiYJ8sjAosPcbOFdr9bnnGbf7 fp6DG7c0xTrb0Wtcjn3/JrKSrE12+CgHND+BBCHSsUoqXnMZNRU+IuUV1RhqIAZQa0WW 9Hi7n+XoZdRs5PjeRJGFQG8qDVmWFJxYj3khUtMQpOCOTWDkih8Iq78qYkO2nx63s4FG GGUKfl1hsu4dHcyQs1LvMrvqCeOkUdbWA+tffxTrMU2dLoKJ8Ak57jcWBRFqz0sVUJCW xZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725644426; x=1726249226; 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=N4LxwlnlL6G3NSnwOnhswZ56WZ0hWrrgxscofAMV3pQ=; b=ek+dDkZKHpgVF6ElPtMroW2WPMbC3llC4PWgnT1N7nhGm01ofZpbPMK7Cq3v89kkxU dRx4mRRawF2+sBDC/aKdQj06vzL9RLR3AUKGucvthd9EFw0sLRhzJkpE9X8cHgz1plXa NFtEYP3GI2zvrpZoQuvG48FPOgUWo4FGf8U8QoRnhi18EGHGFeD/Cbcup+Wa9DcoE1D+ Vnd/kQkOGXnceWSGoq57th6Q0zVGMRhprd+jldjlMwS/UdpN2BsbXv5NyIEHELmOFsPv hmLLZfxcAf7KcesB3D2/+rnKR3x/tVxAsnGcSuNZP3mMk3+keYC1cyhjEBZK/PonJFCM 5BSQ== X-Forwarded-Encrypted: i=1; AJvYcCUWIL27NvQnPSmF8+4AEAQPHHS31n6wF2QVTpu8Wsdip2QsU8UgUov3REWN1ht+DaOmwrWrPYgeWDKt8hdUpLISKEM=@vger.kernel.org, AJvYcCXyGARpRZ4+bOXPNpAj+RtIzefwrz78EqTTAsRC8QaWcppt0p12hqJj3nWwL3/Y7zw2D93XwxFXwdkCH9w=@vger.kernel.org X-Gm-Message-State: AOJu0YzVDeL38fdzZliCUiks3jj5gyOk8+9yALHNtB1anjFnRCiRpeC6 3bexJoVOaskVgui36o1xeWbOaOu0GTxNCB+XuQzbNU5m/1aOjqk1 X-Google-Smtp-Source: AGHT+IEBATDsW2UtMPL1sOLSbyFPMYv4uTIYnh8/ihZ1yE2M2iIHdfCI2vb1325KAmc2aIf1h7Blnw== X-Received: by 2002:a05:6402:1d50:b0:5c2:6b31:29e0 with SMTP id 4fb4d7f45d1cf-5c3c1fa0603mr10397130a12.17.1725644425812; Fri, 06 Sep 2024 10:40:25 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:2595:4364:d152:dff3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3cc697fedsm2623557a12.64.2024.09.06.10.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:40:25 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 2/3] media: platform: rzg2l-cru: rzg2l-video: Retrieve virtual channel information Date: Fri, 6 Sep 2024 18:39:46 +0100 Message-Id: <20240906173947.282402-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906173947.282402-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240906173947.282402-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 RZ/G2L CRU needs to configure the ICnMC.VCSEL bits to specify which virtual channel should be processed from the four available VCs. To retrieve this information from the connected subdevice, the .get_frame_desc() function is called. Signed-off-by: Lad Prabhakar Reviewed-by: Laurent Pinchart --- .../platform/renesas/rzg2l-cru/rzg2l-video.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c index bbf4674f888d..6101a070e785 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c @@ -433,12 +433,41 @@ void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru) spin_unlock_irqrestore(&cru->qlock, flags); } +static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru) +{ + struct v4l2_mbus_frame_desc fd = { }; + struct media_pad *pad; + int ret; + + pad = media_pad_remote_pad_unique(&cru->ip.pads[1]); + if (IS_ERR(pad)) + return PTR_ERR(pad); + + ret = v4l2_subdev_call(cru->ip.remote, pad, get_frame_desc, + pad->index, &fd); + if (ret < 0 && ret != -ENOIOCTLCMD) + return ret; + /* If remote subdev does not implement .get_frame_desc default to VC0. */ + if (ret == -ENOIOCTLCMD) + return 0; + + if (fd.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) + return -EINVAL; + + return fd.num_entries ? fd.entry[0].bus.csi2.vc : 0; +} + int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru) { struct v4l2_mbus_framefmt *fmt = rzg2l_cru_ip_get_src_fmt(cru); unsigned long flags; int ret; + ret = rzg2l_cru_get_virtual_channel(cru); + if (ret < 0) + return ret; + cru->csi.channel = ret; + spin_lock_irqsave(&cru->qlock, flags); /* Select a video input */ From patchwork Fri Sep 6 17:39:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13794488 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.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 F0D061D679A; Fri, 6 Sep 2024 17:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644430; cv=none; b=DOl4HRCclv2jhRDJQ8P8eEhjAOZFjCVGo20BIyX5ZL83FUtNXPT9tjitiFNjq8P+ETnxIvAv39J2JyYP+75LptqpyePEitqOLGkVi0+f81HOzuHBaoUQMLCtu0QVW876xn+Li8ezESCyIN40JWpIrAWfM2Su+fmegOGTdv+YU2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725644430; c=relaxed/simple; bh=Kg1fESNf0X+5YiKDQLqfDlABO5VKIZosjyhbT0lEztE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O3dfjtzQeN9qJiwd79cL/zWkzm9AFjKt1sfxnU+/g2nAFYFtnBKm0uIVvb6ECDg8wPVHtBZ8l5aTWnuyd/lmMfA3mY7uakLuFNi+okkCpYbB/Dw3JrUUIvHxlQGNFsjOfEN42PlpUO+0Txf5hZ9ebHxjJXSxP7KZ8bI0E6MPfsE= 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=AqiZUeT8; arc=none smtp.client-ip=209.85.208.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="AqiZUeT8" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5c260b19f71so2458588a12.1; Fri, 06 Sep 2024 10:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725644427; x=1726249227; 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=zNJfl5F+xChDdawnSeQiz1xfV4q03mnwuTx7Ec+zuZM=; b=AqiZUeT8wHsZQQ+dH9/dDo9FS41ABJ5U4uSm8dDVNaHkoQPOkqZX73MQhknZUF2Ae0 HixAFSkEWmZfwN9fseoT/g5p7Q1emRW4J4mAnz2LKV3CmIXLrwDFFhCkKu4lH+0cLiE0 tRNtyDUhNXHeLFGN/7lrPGsuuT8lStDGDVRpaD6WoMYp9pwYAZbdVMBrdaQdPDbXrU64 PnixRIECozYC1fiqjmcNo7VtmbLX4lN5PCGs1iHOmO0N7FuWcBuBt/8LwNajAdnBAsxt jbL6ieOvsgIcgzc1PVu7vvlTp8y7i01lGib+Fu2+bqBXViLpFR92pcXz9HSFX4+xsiER 4X2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725644427; x=1726249227; 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=zNJfl5F+xChDdawnSeQiz1xfV4q03mnwuTx7Ec+zuZM=; b=iCLngzOAR+GynMfVBkvavvDys/JCZdjqqb8HsdI8QSPEkG5gMktU/Zqah6TRDhZPjV x6oUOFvrO6OlNosimdJgPAJl9Ngr4e6EicZqhTC/AW0ZdkgsGYpJiw49VWstAaBCbyB+ b0xVKhmdeWvuhwR5smcGOcp4FZ3R1drM3bEylMUNo9om+pq/LB6oq+EE393dEE/cjr6Y +hd+B9WStLg/EPH7IUeDmUXAIUYfZeKYgFsifMn/O2vGEJZ2ccHvzZ9iwWi55pCswyGE roRlY9ssrfbr2ZMwOHPHIbgHOOzjbM3SNq3/5cAuuz2e20ZiQopGo6Sj45SSyIiQu7+n n2tg== X-Forwarded-Encrypted: i=1; AJvYcCU2+xR/1OhT1HFsQeQwgMxjyAiQyoRdFfDdCKYFaPFibcg1/CZSomSyV4yDp+6J401675dN8dAVOrkluGs=@vger.kernel.org, AJvYcCXvWTj6dCQ+Na93ILeKi4UPp8ND9BxVSSo+camN+ehSpLUyrlEMasMpfcV9kTaz5C1zlVOAUiJAA2nE9/aGcBrDtL0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywem2wFjbou/ULXtGVAijLQBmP7N1KxJgFl/qmpBIdAAWaVG5z1 bYykOlnhw/bia2/dNEPkiwyeu4Jp6ruGVQVTyLFtyBEvz+ha7DEALbNxcTN3QNo= X-Google-Smtp-Source: AGHT+IEgT20D35Jq7u07g5CPkHIdZkey4MccTXBjTlh7Xr5XvBls1yInooC8Pp9czV7Ju4//M/l4lw== X-Received: by 2002:a05:6402:5386:b0:5a2:68a2:ae57 with SMTP id 4fb4d7f45d1cf-5c3dc7c4c45mr2092216a12.31.1725644426996; Fri, 06 Sep 2024 10:40:26 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:2595:4364:d152:dff3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3cc697fedsm2623557a12.64.2024.09.06.10.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:40:26 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 3/3] media: platform: rzg2l-cru: Add support to capture 8bit raw sRGB Date: Fri, 6 Sep 2024 18:39:47 +0100 Message-Id: <20240906173947.282402-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906173947.282402-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240906173947.282402-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 support to capture 8bit Bayer formats. Signed-off-by: Lad Prabhakar --- .../platform/renesas/rzg2l-cru/rzg2l-cru.h | 5 ++ .../platform/renesas/rzg2l-cru/rzg2l-csi2.c | 7 ++- .../platform/renesas/rzg2l-cru/rzg2l-ip.c | 9 +++- .../platform/renesas/rzg2l-cru/rzg2l-video.c | 51 ++++++++++++++++--- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h index 174760239548..83c664cb0929 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h @@ -58,6 +58,11 @@ struct rzg2l_cru_ip { struct v4l2_subdev *remote; }; +enum rzg2l_cru_fmt { + RZG2L_YUV = 0, + RZG2L_RAW_BAYER, + RZG2L_USER_DEFINED, +}; /** * struct rzg2l_cru_dev - Renesas CRU device structure * @dev: (OF) device diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c index a7e4a0c109da..b14c92cd7c18 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -188,7 +189,11 @@ struct rzg2l_csi2_format { }; static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = { - { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, .bpp = 16 }, + { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 }, + { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, }; static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c index ac8ebae4ed07..5f60be92ea85 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c @@ -6,6 +6,7 @@ */ #include +#include #include "rzg2l-cru.h" struct rzg2l_cru_ip_format { @@ -15,7 +16,11 @@ struct rzg2l_cru_ip_format { }; static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = { - { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, .bpp = 16 }, + { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = MIPI_CSI2_DT_YUV422_8B, .bpp = 16 }, + { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .datatype = MIPI_CSI2_DT_RAW8, .bpp = 8, }, }; enum rzg2l_csi2_pads { @@ -149,7 +154,7 @@ static int rzg2l_cru_ip_enum_frame_size(struct v4l2_subdev *sd, if (fse->index != 0) return -EINVAL; - if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16) + if (!rzg2l_cru_ip_code_to_fmt(fse->code)) return -EINVAL; fse->min_width = RZG2L_CRU_MIN_INPUT_WIDTH; diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c index 6101a070e785..66a0b80e8da7 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -78,6 +79,7 @@ #define ICnMC 0x208 #define ICnMC_CSCTHR BIT(5) #define ICnMC_INF_YUV8_422 (0x1e << 16) +#define ICnMC_INF_RAW8 (0x2a << 16) #define ICnMC_INF_USER (0x30 << 16) #define ICnMC_VCSEL(x) ((x) << 22) #define ICnMC_INF_MASK GENMASK(21, 16) @@ -203,6 +205,10 @@ static int rzg2l_cru_mc_validate_format(struct rzg2l_cru_dev *cru, switch (fmt.format.code) { case MEDIA_BUS_FMT_UYVY8_1X16: + case MEDIA_BUS_FMT_SBGGR8_1X8: + case MEDIA_BUS_FMT_SGBRG8_1X8: + case MEDIA_BUS_FMT_SGRBG8_1X8: + case MEDIA_BUS_FMT_SRGGB8_1X8: break; default: return -EPIPE; @@ -300,7 +306,7 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru) rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr); } -static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv, +static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, enum rzg2l_cru_fmt *input_fmt, struct v4l2_mbus_framefmt *ip_sd_fmt) { u32 icnmc; @@ -308,11 +314,18 @@ static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv, switch (ip_sd_fmt->code) { case MEDIA_BUS_FMT_UYVY8_1X16: icnmc = ICnMC_INF_YUV8_422; - *input_is_yuv = true; + *input_fmt = RZG2L_YUV; + break; + case MEDIA_BUS_FMT_SBGGR8_1X8: + case MEDIA_BUS_FMT_SGBRG8_1X8: + case MEDIA_BUS_FMT_SGRBG8_1X8: + case MEDIA_BUS_FMT_SRGGB8_1X8: + icnmc = ICnMC_INF_RAW8; + *input_fmt = RZG2L_RAW_BAYER; break; default: - *input_is_yuv = false; icnmc = ICnMC_INF_USER; + *input_fmt = RZG2L_USER_DEFINED; break; } @@ -327,17 +340,23 @@ static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv, static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru, struct v4l2_mbus_framefmt *ip_sd_fmt) { - bool output_is_yuv = false; - bool input_is_yuv = false; + enum rzg2l_cru_fmt input_fmt, output_fmt; u32 icndmr; - rzg2l_cru_csi2_setup(cru, &input_is_yuv, ip_sd_fmt); + rzg2l_cru_csi2_setup(cru, &input_fmt, ip_sd_fmt); /* Output format */ switch (cru->format.pixelformat) { case V4L2_PIX_FMT_UYVY: icndmr = ICnDMR_YCMODE_UYVY; - output_is_yuv = true; + output_fmt = RZG2L_YUV; + break; + case V4L2_PIX_FMT_SBGGR8: + case V4L2_PIX_FMT_SGBRG8: + case V4L2_PIX_FMT_SGRBG8: + case V4L2_PIX_FMT_SRGGB8: + icndmr = 0; + output_fmt = RZG2L_RAW_BAYER; break; default: dev_err(cru->dev, "Invalid pixelformat (0x%x)\n", @@ -346,7 +365,7 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru, } /* If input and output use same colorspace, do bypass mode */ - if (output_is_yuv == input_is_yuv) + if (input_fmt == output_fmt) rzg2l_cru_write(cru, ICnMC, rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR); else @@ -809,6 +828,22 @@ static const struct v4l2_format_info rzg2l_cru_formats[] = { .format = V4L2_PIX_FMT_UYVY, .bpp[0] = 2, }, + { + .format = V4L2_PIX_FMT_SBGGR8, + .bpp[0] = 1, + }, + { + .format = V4L2_PIX_FMT_SGBRG8, + .bpp[0] = 1, + }, + { + .format = V4L2_PIX_FMT_SGRBG8, + .bpp[0] = 1, + }, + { + .format = V4L2_PIX_FMT_SRGGB8, + .bpp[0] = 1, + }, }; const struct v4l2_format_info *rzg2l_cru_format_from_pixel(u32 format)