From nobody Tue Dec 2 02:20:29 2025 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 C52F630FC10 for ; Thu, 20 Nov 2025 08:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628587; cv=none; b=cHEM9GNisp3DxJ0Vr4xZcy3iFQ21QVK8TIhKM+mrben7+SoyaHdAs2zwqGv89wSL3I8+F7MhazRs6BqNUf7wxwFdzmp4Z1PfvKnL1DRHUpGJDBLnF3HMQCnjDtJgRAmlTx8nnu4Jwge5kd3ABCfME0qFsEwcSYFsnFFxFd+fNao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628587; c=relaxed/simple; bh=+GZ9/pl+8tJmcSAdMKK7yphZtxzKGCjQy/GcNEI0V8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jj1xWKdiP4/yyPcXs18SHU24ezZAtLYjgK6ZLerbE9zKfHKbbI00v1NYNLB9+ZMDDktLqAeVCjYWaxyRXCL7ZSaGKdy3RoVXg+eAcC9KmQCBOrrLCpg162m0cNh2w1LQ4zDQmXzk2oehbcizAsycB4HNbqPBRgwoAS4arVjx5SM= 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=YgzcJ80C; arc=none smtp.client-ip=209.85.210.180 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="YgzcJ80C" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7b75e366866so286547b3a.2 for ; Thu, 20 Nov 2025 00:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628585; x=1764233385; 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=z/ptnNT0Ywe4s6PcYyycXyPs8DpHI02oawu5aekCWR0=; b=YgzcJ80CMKifbcbzFZqciA/V9Nqj4RY2B3jLB5ApDHUFAy+O5DRxf1CvALO91ultxC U2OsHiUT72YAewqETTxFOtgxuEEdmJ4riExfO96GJWsWc5NvAIuju/lMOHW9VxXcDDzv SldVyy5BSWHzCmHNaBRAK1S69KwsLSDKFNzXAOcanbrANUUjvyRtMMZRDX9lEiKSSMQU cm3DDREiRRKPq/dfuKdbodJgjx6+Ftg9EqKYhmTvOiaA1ltdqUo9QPpCTmYg3YbSlYXL 0uSp9wOUV0oCxiHGJpDR2cYSrx10+DzXfj6vSd9nfTac5r3WjxFy8C9/sAyKLQoZz1Kz 28sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628585; x=1764233385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=z/ptnNT0Ywe4s6PcYyycXyPs8DpHI02oawu5aekCWR0=; b=T6NdsgasJdSqVxwFb4tMkmcWZQQczvShGZky02YdByx/Y6btvwv6erP0p7qtmv0+36 9dDmjVJUVeE8hsTvZT/HouGNDpB9PnnxIoQl2I6OSlYx/V0taf8GQXfFpqHchlg7GHSQ 61yExipIIz3/4M49knI+S9bv7SC/juBu/3XMcPUEjt5+U3kFo+JNF7y4KwFyk65BeWvL gwhSno94dVOIrRmvF1WQouCE0zBceQamyR2eeoxupBwVa2cEsbNjEzvFpAjIqFEbq88A thYcdilJhgPG6cJICRvg/MgmgjhIhhtxaB0/unW/OflbP4mVHAVpr+hNwlka7S3HEK9x Brfg== X-Gm-Message-State: AOJu0YyYzuf5zI9qolegTpvQbEsKsVKZQxIXgqsUMOb65+unP3+EJLLn 7KTp6DQFo2bHLn2YRN28w6GXUtGC+35FE2n83GWnsGuRWvJ3x/4ilA5rJjpoDw== X-Gm-Gg: ASbGnctcSNh8+8c90myboQKKeUnAQoVLHWCQPzEQOWlJzzDHl5zpjagh+yqvuppCchm 574XYw7WezZq7q+F8p9ApTpyujGkEYNXfV7cuv/XEXmJLdhNmMYPrT70GhkoBx3z5ZMFXrrTRsa al3ng+tnY0uQKbLX4SnAaZ9SEQpb77KcpkwlZbz+xa3+O9yigQPXlW93MJDFn5IB/AMCN+R/wmG E9N0OuGu25PiVrhLJVETxvfXMBWDPMWRnGIeHQhDLYQAKexiBf4SkObSpQsy4Zj86/7f43i1kRF O8SY6knfs5dPB0x+coRVqo3Af0t6p049THn3Y0zRyVjsygoSaDhG6KQwgjJEqEkqqmCQWZ0QBc/ 1y+h/nS23Ro6bCsFc095jCjwWFLosWt0uTUk1SVNtinsKkYYMz/92NeWGQPOVevFVkNBRx4N0MX AVFRV5lntOh+T0v5DLg9jDsUn/VRFVX0Zhui1Yi8mnv7UBTKCr X-Google-Smtp-Source: AGHT+IEALagsCqhTRCRlW+YucKP93SC8UvQZZ3c8uhGdG1xhbcDAVp6w1UfBjYuS8RMQv2QHfKnBEQ== X-Received: by 2002:a05:6a00:22d5:b0:781:2291:1045 with SMTP id d2e1a72fcca58-7c3eee84759mr3037945b3a.8.1763628584944; Thu, 20 Nov 2025 00:49:44 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:49:44 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 1/5] media: vimc: add RGB/YUV input entity implementation Date: Thu, 20 Nov 2025 14:19:22 +0530 Message-ID: <20251120084926.18620-2-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a new vimc-input entity to simulate a color frame source in the Virtual Media Controller (VIMC) pipeline. This entity outputs RGB888 frames and allows testing of pipelines that start from a pre-processed RGB/YUV source instead of a raw Bayer sensor. The patch adds vimc-input.c with basic pad operations for format enumeration, get/set, and stream enable/disable handlers. The entity is registered in the VIMC core configuration, replacing the previous temporary use of vimc-sensor. Frame generation is not yet implemented and remains a TODO for future work. This change enables link validation and format negotiation for the RGB/YUV input path, paving the way for software frame injection and test-pattern generation. Signed-off-by: Pavan Bobba --- drivers/media/test-drivers/vimc/Makefile | 3 +- drivers/media/test-drivers/vimc/vimc-common.h | 1 + drivers/media/test-drivers/vimc/vimc-core.c | 3 +- drivers/media/test-drivers/vimc/vimc-input.c | 210 ++++++++++++++++++ 4 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 drivers/media/test-drivers/vimc/vimc-input.c diff --git a/drivers/media/test-drivers/vimc/Makefile b/drivers/media/test-= drivers/vimc/Makefile index 9b9631562473..7e1fdb2f2a78 100644 --- a/drivers/media/test-drivers/vimc/Makefile +++ b/drivers/media/test-drivers/vimc/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 vimc-y :=3D vimc-core.o vimc-common.o vimc-streamer.o vimc-capture.o \ - vimc-debayer.o vimc-scaler.o vimc-sensor.o vimc-lens.o + vimc-debayer.o vimc-scaler.o vimc-sensor.o vimc-lens.o \ + vimc-input.o =20 obj-$(CONFIG_VIDEO_VIMC) +=3D vimc.o =20 diff --git a/drivers/media/test-drivers/vimc/vimc-common.h b/drivers/media/= test-drivers/vimc/vimc-common.h index 7a45a2117748..6c94b1635fa8 100644 --- a/drivers/media/test-drivers/vimc/vimc-common.h +++ b/drivers/media/test-drivers/vimc/vimc-common.h @@ -172,6 +172,7 @@ extern const struct vimc_ent_type vimc_debayer_type; extern const struct vimc_ent_type vimc_scaler_type; extern const struct vimc_ent_type vimc_capture_type; extern const struct vimc_ent_type vimc_lens_type; +extern const struct vimc_ent_type vimc_input_type; =20 /** * vimc_pix_map_by_index - get vimc_pix_map struct by its index diff --git a/drivers/media/test-drivers/vimc/vimc-core.c b/drivers/media/te= st-drivers/vimc/vimc-core.c index f632c77e52f5..2f6846facb23 100644 --- a/drivers/media/test-drivers/vimc/vimc-core.c +++ b/drivers/media/test-drivers/vimc/vimc-core.c @@ -107,9 +107,8 @@ static const struct vimc_ent_config ent_config[] =3D { .type =3D &vimc_capture_type }, [RGB_YUV_INPUT] =3D { - /* TODO: change this to vimc-input when it is implemented */ .name =3D "RGB/YUV Input", - .type =3D &vimc_sensor_type + .type =3D &vimc_input_type }, [SCALER] =3D { .name =3D "Scaler", diff --git a/drivers/media/test-drivers/vimc/vimc-input.c b/drivers/media/t= est-drivers/vimc/vimc-input.c new file mode 100644 index 000000000000..cedcc450d59e --- /dev/null +++ b/drivers/media/test-drivers/vimc/vimc-input.c @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * vimc-input.c Virtual Media Controller Driver + * + * Copyright (C) 2025 Virtual Input Entity Implementation + */ + +#include +#include + +#include "vimc-common.h" + +struct vimc_input_device { + struct vimc_ent_device ved; + struct v4l2_subdev sd; + struct media_pad pad; +}; + +static const struct v4l2_mbus_framefmt fmt_default =3D { + .width =3D 640, + .height =3D 480, + .code =3D MEDIA_BUS_FMT_RGB888_1X24, + .field =3D V4L2_FIELD_NONE, + .colorspace =3D V4L2_COLORSPACE_SRGB, +}; + +static int vimc_input_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_mbus_framefmt *mf; + unsigned int i; + + for (i =3D 0; i < sd->entity.num_pads; i++) { + mf =3D v4l2_subdev_state_get_format(sd_state, i); + *mf =3D fmt_default; + } + + return 0; +} + +static int vimc_input_enum_mbus_code(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->index > 0) + return -EINVAL; + + code->code =3D MEDIA_BUS_FMT_RGB888_1X24; + + return 0; +} + +static int vimc_input_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + const struct vimc_pix_map *vpix; + + if (fse->index) + return -EINVAL; + + /* Only accept code in the pix map table */ + vpix =3D vimc_pix_map_by_code(fse->code); + if (!vpix) + return -EINVAL; + + fse->min_width =3D VIMC_FRAME_MIN_WIDTH; + fse->max_width =3D VIMC_FRAME_MAX_WIDTH; + fse->min_height =3D VIMC_FRAME_MIN_HEIGHT; + fse->max_height =3D VIMC_FRAME_MAX_HEIGHT; + + return 0; +} + +static int vimc_input_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct v4l2_mbus_framefmt *mf; + + mf =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); + + fmt->format =3D *mf; + + return 0; +} + +static int vimc_input_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct v4l2_mbus_framefmt *mf; + + mf =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); + + /* Set the new format */ + *mf =3D fmt->format; + + return 0; +} + +static int vimc_input_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + /* For input entity, we don't allocate frames since we expect + * external frame injection. Just mark that streaming is active. + * + * TODO: For future enhancement, consider implementing frame generation + * or userspace frame injection mechanism. This would require: + * - Frame buffer allocation (similar to vimc-sensor.c) + * - Interface for userspace to inject frames (e.g., via sysfs/debugfs) + * - Frame rate control for generated test patterns + * - Integration with VIMC's streaming infrastructure + * This would make the input entity suitable for more testing scenarios. + */ + return 0; +} + +static int vimc_input_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + /* Streaming stopped - no cleanup needed for input entity */ + return 0; +} + +static const struct v4l2_subdev_pad_ops vimc_input_pad_ops =3D { + .enum_mbus_code =3D vimc_input_enum_mbus_code, + .enum_frame_size =3D vimc_input_enum_frame_size, + .get_fmt =3D vimc_input_get_fmt, + .set_fmt =3D vimc_input_set_fmt, + .enable_streams =3D vimc_input_enable_streams, + .disable_streams =3D vimc_input_disable_streams, +}; + +static const struct v4l2_subdev_ops vimc_input_ops =3D { + .pad =3D &vimc_input_pad_ops, +}; + +static const struct v4l2_subdev_internal_ops vimc_input_internal_ops =3D { + .init_state =3D vimc_input_init_state, +}; + +static void vimc_input_release(struct vimc_ent_device *ved) +{ + struct vimc_input_device *vinput =3D + container_of(ved, struct vimc_input_device, ved); + + v4l2_subdev_cleanup(&vinput->sd); + media_entity_cleanup(vinput->ved.ent); + kfree(vinput); +} + +/* + * Input process frame function + * For an input entity, just return the received frame unchanged + */ +static void *vimc_input_process_frame(struct vimc_ent_device *ved, + const void *frame) +{ + /* For an input entity, just return the received frame unchanged. + * + * TODO: Future enhancement could implement: + * - Frame validation and format checking + * - Frame transformation or processing + * - Frame injection from userspace buffers + * - Frame rate limiting or buffering + * Currently, this is a simple pass-through for external frame sources. + */ + return (void *)frame; +} + +static struct vimc_ent_device *vimc_input_add(struct vimc_device *vimc, + const char *vcfg_name) +{ + struct v4l2_device *v4l2_dev =3D &vimc->v4l2_dev; + struct vimc_input_device *vinput; + int ret; + + /* Allocate the vinput struct */ + vinput =3D kzalloc(sizeof(*vinput), GFP_KERNEL); + if (!vinput) + return ERR_PTR(-ENOMEM); + + /* Initialize the media pad */ + vinput->pad.flags =3D MEDIA_PAD_FL_SOURCE; + + ret =3D vimc_ent_sd_register(&vinput->ved, &vinput->sd, v4l2_dev, + vcfg_name, + MEDIA_ENT_F_IO_V4L, 1, &vinput->pad, + &vimc_input_internal_ops, &vimc_input_ops); + if (ret) + goto err_free_vinput; + + vinput->ved.process_frame =3D vimc_input_process_frame; + vinput->ved.dev =3D vimc->mdev.dev; + + return &vinput->ved; + +err_free_vinput: + kfree(vinput); + + return ERR_PTR(ret); +} + +const struct vimc_ent_type vimc_input_type =3D { + .add =3D vimc_input_add, + .release =3D vimc_input_release +}; --=20 2.43.0 From nobody Tue Dec 2 02:20:29 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 BDFF130FC10 for ; Thu, 20 Nov 2025 08:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628594; cv=none; b=bDQYUrdX7nuZny9aAFnmANV2ELVw+Ka0MSMxO77M1bc7IdIUf3HGEIfxRURSBDDqsYnUsst7NYvsVFroo27mSfHmbyHoc6XDjReBGk2VNm6AAKbNWk1gGayXv4I6e+GsD9yRMx1FgAGLDyMyfxJ/oBGrgf1X6Ie2Yb9cCJ64gfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628594; c=relaxed/simple; bh=+zQAd6/Lx4XwBMrDDvVeD3K00OAGTAt0KqKDT/5MdBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=exj2oCKMczasgsqjkg6J1lb5EPDRkmZYkMqbwyfMyzTnHcjWQ3fgjGeaDnrZIbmUG0KAHEJnQGssJ/zOfxh060RthnL14VSVBy56iWqE7JPerQ+O5c6JQwzfD3CF7BJeqx8B9qlnAOv7ll2tVfypIKDe0sarQXFN5pltVBPzjHc= 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=grH2bmHG; arc=none smtp.client-ip=209.85.210.178 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="grH2bmHG" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7ba49f92362so433007b3a.1 for ; Thu, 20 Nov 2025 00:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628592; x=1764233392; 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=csSbJcLFM5L2vu2gw+h6Q2d5cAu19xceBRmAiyL/H8Q=; b=grH2bmHGAIFzJqvap/DyyULgWyN0a+qTvRuVQAa95XcM47I8ow6QOqQbihec67QyUe X3ympg3nuqyFGRPYF2GbLvKhgIEPQ/xrQcA4pkbHD4JRvA3K4koRHuV+fjSfAyz/LDOy enrCs2BC1e9Z5pVYNAoVJmz5C0XcsLSBiKfEk7eJvcTwCSB6K3lG5yp6UR/29KUnhiEJ teSaABbYkRwT6cTbKz0Tv7vpCMhjtTxYWe/sjkCbZCL97beXIKGTz1lPNwVsEaLGrvLu xA2S/Fz60hGZAoLGOkF0Kp4nzzwvtT92EfGZr76cFJAhz+Wayp8xxFQTshr0P8PQjZg+ 8bFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628592; x=1764233392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=csSbJcLFM5L2vu2gw+h6Q2d5cAu19xceBRmAiyL/H8Q=; b=r/KES/84BKhcq+3tQtkPgI9uzlvENB62/lEWe/gffN5kwadx0ieMvFjaPbwPrZAYaK zEJIxjSZs+VA2HL+Z6/42/8O3KDWqD+/nMUoP7DrbbWDT93O6kufD/xu28P4U3eWvARY Be9N9fekzRf+6jQqkeSMZxRWYF7FrmKYFl0BHjNyzpaxOVkno4WI+vbWf5H3+7COusWN rLX4qDVdj42eNMwJ4SNJRw0PvdA3+mZQX+dknJGM/gdW6pyxk5JNqy9YWNdlT6cH3ZCn S+PMSgwR8sh6/qZ+SlwBRrd06eadl73g695HaKYoKvup6OSzf3ikMSj5UhVbtAjfkbpg 9+jA== X-Gm-Message-State: AOJu0YwtPlS7LJJ+hdxRmm9jGu3YP4McdZochBdhi3gl9sfpRJdlOUJG ciZ2AKhzfb6tKQ4J19aZSFV0AUVQ4bsvg907ae5r2k2jMuXn0FOy7i9R X-Gm-Gg: ASbGncuctnjPW3IgDDEym7CxqYP/B2LIbNr5wT+uVyX/v0HagsEDPPlWu2SG46dmN8y 6oKV0mLA5g2BrRcYr7GtwTEeLr4H2A00Cm8kGAQ684Ey2MKTVjXp1oGOasw73rRuaNUAKDMwyFa l+NOXn4styiuqnCLM6Mol2M21Iz2lutuPewKJtHVUIczIKL1Gf9+PfQ5smNI7a8h/rCbfXCjois dqzijmO0DJaUh3mEq4KKo9/YM7gXBWD/h46P6hyg8R7+X4BFF4QA0TnGG2fqL+4Wr96kzVRXW3n Pa84W6AZ4LmqJq0E07sDiELZNhYp9B71UBL3zsjBy3zpcl1+f3u/1RURZa/qaYWJ27vNtn+8BiN gf9jMeBcFM3wq629+tfCt2HMCrRx8Cjip6BFd0x9/n4KomD0MUeBAsgXNabxbFRtpHB1DoZQHmN Xan+CO0+VS6Pq88MEcatk2xzudPF5VQfpIIv/Difh6b/MhV9qg X-Google-Smtp-Source: AGHT+IEmgiNcjldYedQWRDUNHff3U8cCEAT8yv/OTxc8A9b5LjVo/3OaLWyNtUJbj7gEtzSczrGhzA== X-Received: by 2002:aa7:91d8:0:b0:77f:9ab:f5 with SMTP id d2e1a72fcca58-7c420577385mr1389092b3a.14.1763628591939; Thu, 20 Nov 2025 00:49:51 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:49:51 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 2/5] media: vimc: add support for V4L2_FIELD_ALTERNATE in vimc-sensor Date: Thu, 20 Nov 2025 14:19:23 +0530 Message-ID: <20251120084926.18620-3-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The vimc sensor currently ignores V4L2_FIELD_ALTERNATE and always configures the test pattern generator (TPG) with a progressive field. This patch adds basic handling for the ALTERNATE field type. When userspace requests V4L2_FIELD_ALTERNATE, the TPG is configured to output alternating top and bottom fields by calling tpg_s_field() with the interlaced flag set. For all other field types, existing progressive behaviour is preserved. This change allows the vimc-sensor subdevice to correctly reflect the requested field type in its reported format, enabling basic testing of interlaced-field negotiation in the media pipeline. Other vimc entities (debayer, scaler, capture) still treat all streams as progressive, so streaming with ALTERNATE may not yet succeed. Signed-off-by: Pavan Bobba --- drivers/media/test-drivers/vimc/vimc-sensor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/= test-drivers/vimc/vimc-sensor.c index 027767777763..900c3f329f1c 100644 --- a/drivers/media/test-drivers/vimc/vimc-sensor.c +++ b/drivers/media/test-drivers/vimc/vimc-sensor.c @@ -105,8 +105,10 @@ static void vimc_sensor_tpg_s_format(struct vimc_senso= r_device *vsensor, tpg_s_bytesperline(&vsensor->tpg, 0, format->width * vpix->bpp); tpg_s_buf_height(&vsensor->tpg, format->height); tpg_s_fourcc(&vsensor->tpg, vpix->pixelformat); - /* TODO: add support for V4L2_FIELD_ALTERNATE */ - tpg_s_field(&vsensor->tpg, format->field, false); + if (format->field =3D=3D V4L2_FIELD_ALTERNATE) + tpg_s_field(&vsensor->tpg, V4L2_FIELD_TOP, true); + else + tpg_s_field(&vsensor->tpg, format->field, false); tpg_s_colorspace(&vsensor->tpg, format->colorspace); tpg_s_ycbcr_enc(&vsensor->tpg, format->ycbcr_enc); tpg_s_quantization(&vsensor->tpg, format->quantization); @@ -127,8 +129,7 @@ static void vimc_sensor_adjust_fmt(struct v4l2_mbus_fra= mefmt *fmt) fmt->height =3D clamp_t(u32, fmt->height, VIMC_FRAME_MIN_HEIGHT, VIMC_FRAME_MAX_HEIGHT) & ~1; =20 - /* TODO: add support for V4L2_FIELD_ALTERNATE */ - if (fmt->field =3D=3D V4L2_FIELD_ANY || fmt->field =3D=3D V4L2_FIELD_ALTE= RNATE) + if (fmt->field =3D=3D V4L2_FIELD_ANY) fmt->field =3D fmt_default.field; =20 vimc_colorimetry_clamp(fmt); --=20 2.43.0 From nobody Tue Dec 2 02:20:29 2025 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 046D33115A5 for ; Thu, 20 Nov 2025 08:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628598; cv=none; b=BRjZmFaUK6PSJCmeZqoQacklEF39l6dlNVl20ikVCIadppi8R+CHW4Vx2W8kPs9HaljdDwBuIT5adEA385/TOKqHvWAE1NFpwksKSUzBJKX0qnBPlhZedyviyArYo5lkcJTx2JMzN4DFatNJ9Z9uEW5r+2hzQ9zLo8Xn9g1wM2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628598; c=relaxed/simple; bh=MQV8jD27ZG+yZve5+9joqOYFG9IDBUKao+l7F/BRtLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p9wVrGWuYlg354C/X7fz6ftWIUKFAcsIRZCxrzgPG7xHOnGR55AGlXd5pb6d0fePt4JOj90Q9FPuLctIwPYnF/e7YVgYE82tS2+iHyNxRtkj9Zuaztrw+ZqupxLmfjytYhgXJ61mlU2/Y9glIBNmxiTougT6DVAR7edWqDjZOjc= 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=b46VllM0; arc=none smtp.client-ip=209.85.210.170 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="b46VllM0" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7aace33b75bso573286b3a.1 for ; Thu, 20 Nov 2025 00:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628596; x=1764233396; 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=cGP4x/41RYIg15mQcXh3AwtklkR1Te1lPQnjCYwhFmM=; b=b46VllM0mNbqjcyT1g4C/WwRSsIWjt4RNF2tIrmyQndjZVKW1zH3QbJWmWH1a4J8EM F+ygTVsE2xRue7UDRl14bfqVYB5BnTIJ0D9zwnKu8QbO3ts++mFUYCGuSoycxsTdSHIJ ytjJigcJeK8FhjQu9LeE5UVmBilitFIqLYRzY8rYGI4KuRPC4x3e+iVWxAyk7MKvwHpT XH71mAJXXOp+PdYFiDV4wJhPCH4UA6zbmqQDSRjY1YfjTPkYY6o2rYdJabov6ityAtt6 QiScSGL/i7FUFVyCQlAP2fFUb2I+7+2YCAswpIH8ZJiD12Q4ZKUABARCQlCu1Evw0a+h fW7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628596; x=1764233396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cGP4x/41RYIg15mQcXh3AwtklkR1Te1lPQnjCYwhFmM=; b=tn6fqBS1fjkslBjG78D9B0T4MGdCXET+4K2JTf6Is+JO/baeSQj2eH7aL8e+e5SQ9d 8nif+zcCoXJ6zbwAwZ621u18eBOdvsxpy4PSQFI6NYIvYeJ7VbMcJOWAjtkT1OR8EAaJ DJJdcAnhmOW4ipOr6ro6Du3PenOYXMPBqjbm75Yr77oJcMBG1tQ+ui6opWnild6gdl6t xtA8ZYFYm22qcMzidUYmN+Wf+OooB6LAVum7O23Y/YUn46coOlnPrOZsKhbsTAwRWJGR CCP+xBC3StQxAp1/JxlgYlv36bXzJG4AAEh+GqG/Fc/U8uOvUV+9D2nhZ1IEMvC7hPLe 2qig== X-Gm-Message-State: AOJu0YwqUnJowKgdDr7Xxb6RaOg5I4Poqox8TaYMzjza3he1VZfhYfLE Mlo65OwCw7WE6qQ50jAzi9QxOiFA4lHe31phqjUm77De8BAtEUz+PxXZ X-Gm-Gg: ASbGncsjXs8ZpxBcabuS/InExMBweB4xGU2HD6TK1IfRkFqSd2Zvw1i816pDpJyeYXA rzZxGfjjDb/ZNhEGIszf00JvYE1appxkME4tehNvHwrY8R1g5D9+NHyu8sYSo2h4846W0SJdnGy eR9fugYiGIUGxMp7JfYmEnbu3Aha7Rp/QT1GIJk1KrN+vFe3bBJpFuVaqxpnQ7RvHxIJx1xt5oj 9UmNW/AhDsnFOXFmLDrxavcWUO0o/UMtOhttzEdLrHSsGPf1+geI5+fgtU5jJAL82EtuAQHIgqW OF3bwBjV0Syoj6+E/rGspbXQVAMyBRfOvs+dBhtKh2wDblnUnFLUkFBzUw+ze/9W0s0bsU3QeES /sW69CmuDyBd66iaaw6Yy/M3mVq3gB2HSxHuri1JWjO/dWgy4SG2R2vJ4dwlA6LAOX45lcYVo0c 82Mq4J8hXN9r5N37XxnS52yHZGD4HiOeOIP9xKtg== X-Google-Smtp-Source: AGHT+IECkCFNKIq/dOmcM+rn72ZbItA41tgJJU1WjHJ7EZr5qY/C2DRz99gNei/A0E9dQvLJp0yjFQ== X-Received: by 2002:a05:6a00:c8f:b0:7a9:b9e0:551c with SMTP id d2e1a72fcca58-7c3f095c12fmr2797914b3a.21.1763628596176; Thu, 20 Nov 2025 00:49:56 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:49:55 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 3/5] media: vimc: debayer: add support for multiple RGB formats Date: Thu, 20 Nov 2025 14:19:24 +0530 Message-ID: <20251120084926.18620-4-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enhance the vimc debayer subdevice to support multiple RGB output formats and improve its format negotiation behavior. This patch introduces the following changes: - Adds ARGB8888_1X32 to the list of supported source pad mbus codes. - Allows userspace to select any valid RGB code on the source pad through set_fmt(). - Propagates width, height, and field settings from sink to source while preserving the selected RGB code. - Sets appropriate default colorimetry for RGB output (sRGB, full-range). - Updates vimc_debayer_process_rgb_frame() to handle RGB24, BGR24, and ARGB32 pixel formats with proper channel ordering and alpha fill. - Adds debug and warning logs for invalid or unsupported formats. These changes make the virtual debayer pipeline more flexible and realistic for testing RGB/ARGB camera capture paths. Signed-off-by: Pavan Bobba --- .../media/test-drivers/vimc/vimc-debayer.c | 113 ++++++++++++++---- 1 file changed, 90 insertions(+), 23 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-debayer.c b/drivers/media= /test-drivers/vimc/vimc-debayer.c index bbb7c7a86df0..0fa1cb8d3be1 100644 --- a/drivers/media/test-drivers/vimc/vimc-debayer.c +++ b/drivers/media/test-drivers/vimc/vimc-debayer.c @@ -15,9 +15,6 @@ =20 #include "vimc-common.h" =20 -/* TODO: Add support for more output formats, we only support RGB888 for n= ow. */ -#define VIMC_DEBAYER_SOURCE_MBUS_FMT MEDIA_BUS_FMT_RGB888_1X24 - enum vimc_debayer_rgb_colors { VIMC_DEBAYER_RED =3D 0, VIMC_DEBAYER_GREEN =3D 1, @@ -73,6 +70,7 @@ static const u32 vimc_debayer_src_mbus_codes[] =3D { MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, MEDIA_BUS_FMT_RGB888_1X32_PADHI, + MEDIA_BUS_FMT_ARGB8888_1X32, }; =20 static const struct vimc_debayer_pix_map vimc_debayer_pix_map_list[] =3D { @@ -170,7 +168,7 @@ static int vimc_debayer_init_state(struct v4l2_subdev *= sd, =20 mf =3D v4l2_subdev_state_get_format(sd_state, 1); *mf =3D sink_fmt_default; - mf->code =3D VIMC_DEBAYER_SOURCE_MBUS_FMT; + mf->code =3D vimc_debayer_src_mbus_codes[0]; =20 return 0; } @@ -239,6 +237,14 @@ static void vimc_debayer_adjust_sink_fmt(struct v4l2_m= bus_framefmt *fmt) vimc_colorimetry_clamp(fmt); } =20 +static void vimc_debayer_set_rgb_mbus_fmt_default(struct v4l2_mbus_framefm= t *fmt) +{ + fmt->colorspace =3D V4L2_COLORSPACE_SRGB; + fmt->quantization =3D V4L2_QUANTIZATION_FULL_RANGE; + fmt->xfer_func =3D V4L2_XFER_FUNC_SRGB; + fmt->ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT; +} + static int vimc_debayer_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) @@ -250,12 +256,30 @@ static int vimc_debayer_set_fmt(struct v4l2_subdev *s= d, if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE && vdebayer->src_frame) return -EBUSY; =20 - /* - * Do not change the format of the source pad, it is propagated from - * the sink. - */ - if (VIMC_IS_SRC(fmt->pad)) - return v4l2_subdev_get_fmt(sd, sd_state, fmt); + if (VIMC_IS_SRC(fmt->pad)) { + struct v4l2_mbus_framefmt *source_fmt; + struct v4l2_mbus_framefmt *sink_fmt; + + /* Validate the requested source format */ + if (!vimc_debayer_src_code_is_valid(fmt->format.code)) + return -EINVAL; + + /* Get current formats */ + source_fmt =3D v4l2_subdev_state_get_format(sd_state, 1); + sink_fmt =3D v4l2_subdev_state_get_format(sd_state, 0); + + /* Update source format with appropriate properties for RGB output */ + source_fmt->code =3D fmt->format.code; + source_fmt->width =3D sink_fmt->width; /* Size should match */ + source_fmt->height =3D sink_fmt->height; /* Size should match */ + source_fmt->field =3D sink_fmt->field; /* Field handling should match = */ + + /* Set appropriate colorimetry for RGB output */ + vimc_debayer_set_rgb_mbus_fmt_default(source_fmt); + + fmt->format =3D *source_fmt; + return 0; + } =20 /* Set the new format in the sink pad. */ vimc_debayer_adjust_sink_fmt(&fmt->format); @@ -278,8 +302,25 @@ static int vimc_debayer_set_fmt(struct v4l2_subdev *sd, =20 /* Propagate the format to the source pad. */ format =3D v4l2_subdev_state_get_format(sd_state, 1); - *format =3D fmt->format; - format->code =3D VIMC_DEBAYER_SOURCE_MBUS_FMT; + + /* Propagate size and field from sink, but maintain source code */ + format->width =3D fmt->format.width; + format->height =3D fmt->format.height; + format->field =3D fmt->format.field; + + /* + * Source code should always be valid (set during init or via set_fmt). + * If somehow it's not, this is a bug - log warning and fix it. + */ + if (!vimc_debayer_src_code_is_valid(format->code)) { + dev_warn(vdebayer->ved.dev, + "%s: Invalid source code 0x%x, resetting to default\n", + vdebayer->sd.name, format->code); + format->code =3D vimc_debayer_src_mbus_codes[0]; + } + + /* Set appropriate colorimetry for RGB output */ + vimc_debayer_set_rgb_mbus_fmt_default(format); =20 return 0; } @@ -297,19 +338,45 @@ static void vimc_debayer_process_rgb_frame(struct vim= c_debayer_device *vdebayer, unsigned int rgb[3]) { const struct vimc_pix_map *vpix; - unsigned int i, index; + unsigned int index; =20 vpix =3D vimc_pix_map_by_code(vdebayer->hw.src_code); - index =3D VIMC_FRAME_INDEX(lin, col, vdebayer->hw.size.width, 3); - for (i =3D 0; i < 3; i++) { - switch (vpix->pixelformat) { - case V4L2_PIX_FMT_RGB24: - vdebayer->src_frame[index + i] =3D rgb[i]; - break; - case V4L2_PIX_FMT_BGR24: - vdebayer->src_frame[index + i] =3D rgb[2 - i]; - break; - } + if (!vpix) { + dev_dbg(vdebayer->ved.dev, "Invalid source code: 0x%x\n", + vdebayer->hw.src_code); + return; + } + + index =3D VIMC_FRAME_INDEX(lin, col, vdebayer->hw.size.width, vpix->bpp); + + switch (vpix->pixelformat) { + case V4L2_PIX_FMT_RGB24: + /* RGB24: R-G-B */ + vdebayer->src_frame[index + 0] =3D rgb[0]; /* Red */ + vdebayer->src_frame[index + 1] =3D rgb[1]; /* Green */ + vdebayer->src_frame[index + 2] =3D rgb[2]; /* Blue */ + break; + + case V4L2_PIX_FMT_BGR24: + /* BGR24: B-G-R */ + vdebayer->src_frame[index + 0] =3D rgb[2]; /* Blue */ + vdebayer->src_frame[index + 1] =3D rgb[1]; /* Green */ + vdebayer->src_frame[index + 2] =3D rgb[0]; /* Red */ + break; + + case V4L2_PIX_FMT_ARGB32: + /* ARGB32: A-R-G-B (set alpha to 255) */ + vdebayer->src_frame[index + 0] =3D 255; /* Alpha */ + vdebayer->src_frame[index + 1] =3D rgb[0]; /* Red */ + vdebayer->src_frame[index + 2] =3D rgb[1]; /* Green */ + vdebayer->src_frame[index + 3] =3D rgb[2]; /* Blue */ + break; + + default: + dev_dbg(vdebayer->ved.dev, + "Unsupported pixel format for debayer: 0x%x\n", + vpix->pixelformat); + break; } } =20 --=20 2.43.0 From nobody Tue Dec 2 02:20:29 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 1CE7F311C22 for ; Thu, 20 Nov 2025 08:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628602; cv=none; b=Ay8s+Xd0purTNh3Xvrel7xGMIuhxk/A1nGzDdvC3g8VjirhBPztsGY9/fUkh0/qgT2uMLq0JL2GJT1415dznEwuRUGblRXujkCFRrj7kSInWBuRmNtRN+y3DXG3/qDw54lgMha2NrpyObc0R/ykTByHSFQ2Mn7Ff+ASR0OPNBNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628602; c=relaxed/simple; bh=q9U2/lglyvUZ+6SzKjNSNlDwmEjWmsKN97d6E/pOIIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUpeZPGJ2itZDLZ2ejUGl7Ya/M7e5OFxIBMZrDYBClLAag9zvIflbg4VQHY7yRBz0FAivdKDbL8ebwbprcjdCDBSTzQXWI1sKYYPabN26DeG+tZMjtzjkF4FPOfTSPPlVl+uEUPSraRUntRUQbMeiYNrK8+J8KGeMtViK7dZu/Q= 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=GB/nbm5C; arc=none smtp.client-ip=209.85.210.178 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="GB/nbm5C" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7b852bb31d9so803943b3a.0 for ; Thu, 20 Nov 2025 00:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628600; x=1764233400; 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=n7GOu69hsNGmnIy0MHORKTrtvDnS7Wvg9FFJEsAiMq0=; b=GB/nbm5CqaiIYh0XzpNVZ5KKW85pPhZu50I/z6bZj3F1GEouQBSqfXaawMQSfm1zdN n/ndc7T3CFr3ISkX+d8FknMTZx4eDPnfR8YDkLYr1axwAypJx+8koiyh4GUap45h+IZT 5PFzN9/fyNUdLjsLD98KAgsLefYfA4xsZTgQp2bTNjV+iAKhWklnzTVUssiiWsuTWOv0 6RLJm534RfDTljqQhEVZYNkZtEtpwRIZ+c+rZNWaozyfYfjGDsdjxRks25i0k3oC5NIo 1y1kJK+LmfvatzP23yiI+G9mfk8G1cVYtZkgb/qXJVsvAiXFuYUVo3khkrDB1ls3bWoA gylQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628600; x=1764233400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=n7GOu69hsNGmnIy0MHORKTrtvDnS7Wvg9FFJEsAiMq0=; b=MOj8kzpcQtRyBG43Sr82GIbflav6XKdrIc6hHVhFaqRxMYHs7DNd9C1meqo5RvqhCy Sz5VWUHpX9A080E66Gr9nWnDevmkcKqPOn66RfyetixipXVylDC6GAgNFBVrNm3TGFbf LPgW0m0k8xMD/I6P70P+l1HUwNXCbtGz0zb6RGo9LfEGGaeEojiuxlBypOnwEc1i1oNJ wvY8r3NCfwsGSBeAyd8/PQOda12O7j1d5cOPgioyzsubj29UCaBLtDd1JlNECxt4Td6Y y7ErGz3Q2bjnpgifwJoyoFVts9Y3L6bN4RqdutubKljtUtKlUSRMpV4kYFIQP1in4axU nGJw== X-Gm-Message-State: AOJu0YxFuUCBhfAYOHEoifKUCYOEJ48uic6ij+uHk+EfUZPTirfF3h5c NnCxK3DKgLVw5TQRH2RoZ26w5oOjQ1gX5sl155Dcn+eNXYwfMIJPr7Sc X-Gm-Gg: ASbGncsQkSyrtuRtQr0YyCu0Ey7XrvkZQAexzv77Z7TyBbQQ+S15zzQEz/yNmtOHD2w loRFI1LPSlB3a0Hl/GWkhiuqEcEFyhZnsqMHTfPBZnYCUFYz8FOfvUK+vtNfSyBGSRreuB+LXu9 AvTIfJmDxRGo5+X8MENCJ44XjgPYyVghFU09z95Zv4HwEKD9m6DIRq0ZiCfdabZt2dF5J1VevDo ufB4Lwv7U1BUSWlKyliqxZs8YguUwcLKeR5yopfdKoVcWT5ZcDJpOycr2L4u8cx1c237pTwMmMV y/iBS5+jRe9LyYp7IMTR2SRj6d8EUIxSNLMAlbEnhnKnKcR8E+rojIZ8B8mD5LAVDw9adYDBcnt Dt0X4Amgyr3ZPwkRwlCko3PhZLzOQB70syZHnbTF1aQE4vvB8EZe5XnG8xc4BxitOHXMsGs+ShB BMITnS963JNehFuA5GaIjySuzJmLKM8qYgCzrxrP/SCuIu4iWp X-Google-Smtp-Source: AGHT+IETrPi74BdCXGprduZagz7q3BGs8jaQJi/0NaAzVeg4Go0h6DCV8yKgZzo5mAFfrmlHcc2nJA== X-Received: by 2002:a05:6a20:3d1a:b0:35e:6a5b:cbc9 with SMTP id adf61e73a8af0-3613b62b45fmr3420426637.50.1763628600413; Thu, 20 Nov 2025 00:50:00 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:50:00 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 4/5] media: vimc: capture: support custom bytesperline values Date: Thu, 20 Nov 2025 14:19:25 +0530 Message-ID: <20251120084926.18620-5-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow userspace to request custom bytesperline (stride) values in the vimc capture driver. The driver now clamps the requested value to a valid range instead of forcing a fixed stride. The minimum bytesperline is width * bytes_per_pixel, while the maximum is limited by VIMC_FRAME_MAX_WIDTH * bytes_per_pixel. This makes the virtual capture node behave more like real hardware that supports aligned or padded scanlines. Signed-off-by: Pavan Bobba --- drivers/media/test-drivers/vimc/vimc-capture.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media= /test-drivers/vimc/vimc-capture.c index 7f6124025fc9..7164ec51eb80 100644 --- a/drivers/media/test-drivers/vimc/vimc-capture.c +++ b/drivers/media/test-drivers/vimc/vimc-capture.c @@ -85,6 +85,7 @@ static int vimc_capture_try_fmt_vid_cap(struct file *file= , void *priv, { struct v4l2_pix_format *format =3D &f->fmt.pix; const struct vimc_pix_map *vpix; + u32 min_bpl, max_bpl; =20 format->width =3D clamp_t(u32, format->width, VIMC_FRAME_MIN_WIDTH, VIMC_FRAME_MAX_WIDTH) & ~1; @@ -97,8 +98,18 @@ static int vimc_capture_try_fmt_vid_cap(struct file *fil= e, void *priv, format->pixelformat =3D fmt_default.pixelformat; vpix =3D vimc_pix_map_by_pixelformat(format->pixelformat); } - /* TODO: Add support for custom bytesperline values */ - format->bytesperline =3D format->width * vpix->bpp; + + /* Calculate the minimum supported bytesperline value */ + min_bpl =3D format->width * vpix->bpp; + /* Calculate the maximum supported bytesperline value */ + max_bpl =3D VIMC_FRAME_MAX_WIDTH * vpix->bpp; + + /* Clamp bytesperline to the valid range */ + if (format->bytesperline > max_bpl) + format->bytesperline =3D max_bpl; + if (format->bytesperline < min_bpl) + format->bytesperline =3D min_bpl; + format->sizeimage =3D format->bytesperline * format->height; =20 if (format->field =3D=3D V4L2_FIELD_ANY) --=20 2.43.0 From nobody Tue Dec 2 02:20:29 2025 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 63319312816 for ; Thu, 20 Nov 2025 08:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628608; cv=none; b=IA0EHS40XKaZEcrmjM6cTcvaEhW1TVAWNiz0eMj/1t6t2SGjY00Ka8uo2MoouOjZIal11uwBaB5oHrnufViBNe5mhydr/3N7hCwXGQTLcqceA6RwyMNkMe3Dy3Yl8PTr10BaBL0QWtbYYGbhP3kcze/n4jquoXj+zHriM1VH588= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763628608; c=relaxed/simple; bh=M+mW+WSULXXoA2BJG/VmR/L0N4mc6VSqrlTT8ZT02VE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A2AXp7BVWQ2BDwcuPe1jSa0MesDTIPWMaosLp946rWOScp3qCg/CFM75md1Fe7WKI4LvhAELLA7asGs/FxO5+ZLs7L0YlQ14G8qrHopiJHPAikyv9eRvpBeYLOXRHqjbeCJkcF6SHD67iFjLxDJXl6NKLByHfq3OiqZY8EgAa0M= 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=WR1A0gyi; arc=none smtp.client-ip=209.85.210.182 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="WR1A0gyi" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso692402b3a.3 for ; Thu, 20 Nov 2025 00:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763628605; x=1764233405; 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=8wulNorrU/LplRsqFdq/jjsuNqQC6CdMEcWXsJuIvbw=; b=WR1A0gyi+E2jXsw2TGeEcwQmbP4NferyRRhD/wbKNW2R7HfSnUeM6z4zkq7Wy/WwID b4nZIqFljQnIsmCS3wwQefnAG9Ypu5vBYj6eXxf2jAQPioJN/h3cng3nzEupGksVTZ3H Lv4no8aHFCS9zGPql6TQuXrMXvLN+MPH2t3XHOe/O7RF2PlSRD4dbnicY//GE837uQhF KoK/QalWdWn8xggE2t5z1Eo8pxFfv0JKXYSQ64Y/MHNYp5KjeEFrar6KxlBGv3sDMju6 PtiLBYBldvfiHzJVPZjaJkD9W9DYGg1X7/AGT1rX5SYkQtvj7XWPoIUL8ti6VLWFrK1U bCHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763628605; x=1764233405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8wulNorrU/LplRsqFdq/jjsuNqQC6CdMEcWXsJuIvbw=; b=YqC/Ay0TUhzuQfAg1povyH1q0oSX7levmzYbAbjuSAtBL36WtTl8yrlBq67O/Zi7i3 oy0HqT38e5Slu36h5LYyMowQyaxwNfcQgRbDgQdDg8NzAiYFGbB1yB++dm3FzwqVqDXS s0FhI2h1u8pnaztynIGsJSeW5VVb76BxyKUhC215uz3Q6sw8WiBarI8KROtLXxzmzQpn 7qCXlq1YwDw7sG3jqu20J4GHUzfglic9c2hcMcE9VCXV/OHyutY0uXrBgDGR0pFHDqjR 3Iaid+F5KChDqHqUgFknoGaqhuOxtSzYAHmReIA2FDm5W5td21rkQ0wsuK1OH5KouGRJ eE3A== X-Gm-Message-State: AOJu0Ywg7oacbuA2Wo/YEXk06kva5NOTvOOpHN6w5+z7IRIAA4IRWplc 1OHfxAokXl/PBmZriI7tWSWM1VepJ1Nq8ZgckoXaE4kGdmqlwMmgDEaXTY0F7A== X-Gm-Gg: ASbGncvnwKe2zzGo1mCEQ+63TmZQxubG1MkzfCpbTZfRAQ1AGJYBeAZJg4eeOV0k1ju TRguS932F8JTRexYTMr2+LytVV/8IUNmMbLx16+9zx4l9uQv1iU/WBQibDNqLZnFwWyjSI+sZP8 xHiyZ/fND+kl5u2fUXa86AoLVhSvvLlaSlhT7hGCbiYVy9K0JMDdiYjKbcFxLGiGE4bmnrBUGnK S868UKc147iGEnzn6nn4E+1sqyotLVX1nGM5OnTFPBx6/Zt4Taz10R8N2pSwFB8pyPrbAw7iv7/ /N7pruCmRVCAVMYtU2oXV7PgEVKxDnY/V6qG0ZVYSxfpJBsx9o+tc59CdN8voHLDPq5t1U+qVrC +s8iQrXHfKWmYRb50SvR0/SvwRfu4I6J5UBpZYki4T5+x6io99iB1urKG+TSrdy1Mdm2BLjpHZv 0/D7WYvu1uZsQIdDTwzD0tVUER/xc7Sx73ri4PCw== X-Google-Smtp-Source: AGHT+IGtuUW0eOH4iDC4C4u0pWDQHVhkJCMz9yoff/QHqW4CoAGSE5E7MXTOxDhAJhNsBCykPSB0tA== X-Received: by 2002:a05:6a00:23d5:b0:7aa:d434:69d6 with SMTP id d2e1a72fcca58-7c4343e34ccmr1973989b3a.10.1763628604575; Thu, 20 Nov 2025 00:50:04 -0800 (PST) Received: from opensource206.. ([157.50.102.16]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm1974900b3a.41.2025.11.20.00.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 00:50:04 -0800 (PST) From: Pavan Bobba To: skhan@linuxfoundation.org, kieran.bingham@ideasonboard.com, mchehab@kernel.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pavan Bobba Subject: [PATCH 5/5] docs: media: vimc: document RGB/YUV input entity Date: Thu, 20 Nov 2025 14:19:26 +0530 Message-ID: <20251120084926.18620-6-opensource206@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120084926.18620-1-opensource206@gmail.com> References: <20251120084926.18620-1-opensource206@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update the vimc admin guide to describe the RGB/YUV input entity and show how to use it in a pipeline. The existing media-ctl and v4l2-ctl examples are updated to: Use the correct device name, platform:vimc.0. Keep the original sensor =E2=86=92 debayer =E2=86=92 scaler pipeline exampl= e. Add a new example that switches the scaler input to the RGB/YUV entity and requests ARGB output with a padded capture stride via bytesperline. A new vimc-input subdevice section documents the RGB/YUV frame source entity, its default RGB888 bus format, and how it can be used for software-driven frame injection in pipelines that start after a real debayer stage. This makes it easier for users to understand and exercise the RGB/YUV input entity in vimc-based experiments. Signed-off-by: Pavan Bobba --- Documentation/admin-guide/media/vimc.rst | 39 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/media/vimc.rst b/Documentation/admin= -guide/media/vimc.rst index 29d843a8ddb1..a1b7de769e23 100644 --- a/Documentation/admin-guide/media/vimc.rst +++ b/Documentation/admin-guide/media/vimc.rst @@ -4,7 +4,7 @@ The Virtual Media Controller Driver (vimc) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 The vimc driver emulates complex video hardware using the V4L2 API and the= Media -API. It has a capture device and three subdevices: sensor, debayer and sca= ler. +API. It has a capture device and three subdevices: sensor, debayer, scaler= and RGB/YUV input entity. =20 Topology -------- @@ -29,17 +29,28 @@ configuration on each linked subdevice to stream frames= through the pipeline. If the configuration doesn't match, the stream will fail. The ``v4l-utils`` package is a bundle of user-space applications, that comes with ``media-ct= l`` and ``v4l2-ctl`` that can be used to configure the vimc configuration. This se= quence -of commands fits for the default topology: +-of commands fits for the default topology: =20 .. code-block:: bash =20 - media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480= ]' - media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x48= 0]' - media-ctl -d platform:vimc -V '"Scaler":0[fmt:RGB888_1X24/640x480]' - media-ctl -d platform:vimc -V '"Scaler":0[crop:(100,50)/400x150]' - media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/300x700]' - v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=3D300,heig= ht=3D700 - v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=3DBA81 + media-ctl -d platform:vimc.0 -V '"Sensor A":0[fmt:SBGGR8_1X8/640x4= 80]' + media-ctl -d platform:vimc.0 -V '"Debayer A":0[fmt:SBGGR8_1X8/640x= 480]' + media-ctl -d platform:vimc.0 -V '"Scaler":0[fmt:RGB888_1X24/640x48= 0]' + media-ctl -d platform:vimc.0 -V '"Scaler":0[crop:(100,50)/400x150]' + media-ctl -d platform:vimc.0 -V '"Scaler":1[fmt:RGB888_1X24/300x70= 0]' + v4l2-ctl -z platform:vimc.0 -d "RGB/YUV Capture" -v width=3D300,he= ight=3D700 + v4l2-ctl -z platform:vimc.0 -d "Raw Capture 0" -v pixelformat=3DBA= 81 + +The following commands switch the scaler input to the RGB/YUV entity and r= equest +ARGB output with a padded capture stride. + +.. code-block:: bash + + media-ctl -d platform:vimc.0 -V '"RGB/YUV Input":0[fmt:RGB888_1X24= /640x480]' + media-ctl -d platform:vimc.0 -V '"Scaler":0[fmt:RGB888_1X24/640x48= 0]' + media-ctl -d platform:vimc.0 -V '"Scaler":1[fmt:ARGB8888_1X32/640x= 480]' + v4l2-ctl -z platform:vimc.0 -d "RGB/YUV Capture" \ + -v pixelformat=3DRGB3,width=3D640,height=3D480,bytesperlin= e=3D4096 =20 Subdevices ---------- @@ -53,6 +64,16 @@ vimc-sensor: =20 * 1 Pad source =20 +vimc-input: + Simulates an RGB/YUV frame source for pipelines that start after a real + debayer stage. It exposes a single source pad that initially advertises + ``MEDIA_BUS_FMT_RGB888_1X24`` and accepts the usual width/height updat= es via + ``media-ctl``, which is useful for software-driven frame injection + experiments. + Exposes: + + * 1 Pad source + vimc-lens: Ancillary lens for a sensor. Supports auto focus control. Linked to a vimc-sensor using an ancillary link. The lens supports FOCUS_ABSOLUTE --=20 2.43.0