From patchwork Fri Feb 3 19:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 650728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 633CAC6379F for ; Fri, 3 Feb 2023 19:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbjBCTR0 (ORCPT ); Fri, 3 Feb 2023 14:17:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233325AbjBCTRZ (ORCPT ); Fri, 3 Feb 2023 14:17:25 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEECA6C10B for ; Fri, 3 Feb 2023 11:17:22 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id q8so4618487wmo.5 for ; Fri, 03 Feb 2023 11:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=kfzqUS/ISMtqujGi5r+HM5qWXhRYCbGlaSQrST7SLwo=; b=dqutk9GlnBQSpuKhf1i5+Rm8vNkS4vE/hyvmT23IPkT7VXUAtxGDGHPIx8YJ84g/IW XPEvYSeaEG1Cv/06WGwkOHJfApD5TKaLHi4VnF64/CqXo19l1mlnj7Ly8tOFp0gOJTf3 5HY3l4xwFoVFDmKiIMdLtlIJGRkyTS1OJqEo50ZRCn8Imq7JU4uCeevjkr9If+Fbl3zD dwkJNvc7X800g/+LVhF+ySeJvk7N6KgfIkrgLHwX5b7cR8wQ1fttYrg6HinVTfi5S0Ig bZ51AQYTvoysYp60UMpL+SjGp0PnZa9HnwqOssfW9s4nWBGrzbrrY9/ABzDQREpm+N/H 0vlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kfzqUS/ISMtqujGi5r+HM5qWXhRYCbGlaSQrST7SLwo=; b=JDVc38QzDiQIO/bsd4caXOfNn9y8mFV/6i/EukLrRlnGkL0OvmiwOgGN7tPLD1FXzg c9ZtqFchMhAmauRXgn07FmVyPAxBd6iLecEz5EjQKlztEgiVRBbe+v5SlgsBDWmjNabk 4/T0fqKqm/1bAzpNl2rv9H/iD4z7WmwEwSyNwaRezdIMLMwvaj/I3O8I6hLy63tknzoD qiQeNhWE2i4l0ZT6dx0RiD/eD9QkZLYg8uR/4bmB/aVA3sWCnnoqRMnyagXM3yynx04b bR1N0yRyMU44lZl4mpm1D1aXo5YO8YzDqS6bGr4sTlR/8OB+YZHv+VqAzpaR8cmuVhNr kOXw== X-Gm-Message-State: AO0yUKWZfN1KLGnan1Om94sKStAbJliRJq6CVcUojxzKaW3O1Y+35scW HOrxfiRsBfANVIx/iWfxZSa7tg== X-Google-Smtp-Source: AK7set+wRgr97cAa7Ylthm7pFC6qkj1IxU8Sqeie6yidZdvWqrjtKmsWEw/gmvkT9NwRIg0awEg6SA== X-Received: by 2002:a1c:7906:0:b0:3d3:49db:9b25 with SMTP id l6-20020a1c7906000000b003d349db9b25mr10830652wme.26.1675451841452; Fri, 03 Feb 2023 11:17:21 -0800 (PST) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id l20-20020a05600c089400b003dc41a9836esm3349263wmp.43.2023.02.03.11.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:17:21 -0800 (PST) From: Dave Stevenson To: Manivannan Sadhasivam , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Alexander Stein Cc: Dave Stevenson , Rob Herring Subject: [PATCH v2 1/2] media: dt-bindings: media: i2c: Add mono version to IMX290 bindings Date: Fri, 3 Feb 2023 19:16:43 +0000 Message-Id: <20230203191644.947643-2-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203191644.947643-1-dave.stevenson@raspberrypi.com> References: <20230203191644.947643-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The IMX290 module is available as either monochrome or colour and the variant is not detectable at runtime. Add a new compatible string for the monochrome version. Signed-off-by: Dave Stevenson Acked-by: Rob Herring Reviewed-by: Laurent Pinchart --- .../bindings/media/i2c/sony,imx290.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx290.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx290.yaml index 21377daae026..dacecb0cd9aa 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx290.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx290.yaml @@ -12,15 +12,23 @@ maintainers: description: |- The Sony IMX290 is a 1/2.8-Inch CMOS Solid-state image sensor with Square - Pixel for Color Cameras. It is programmable through I2C and 4-wire - interfaces. The sensor output is available via CMOS logic parallel SDR - output, Low voltage LVDS DDR output and CSI-2 serial data output. The CSI-2 - bus is the default. No bindings have been defined for the other busses. + Pixel, available in either mono or colour variants. + It is programmable through I2C and 4-wire interfaces. + + The sensor output is available via CMOS logic parallel SDR output, Low voltage + LVDS DDR output and CSI-2 serial data output. The CSI-2 bus is the default. + No bindings have been defined for the other busses. + + imx290lqr is the full model identifier for the colour variant. "sony,imx290" + is treated the same as this as it was the original compatible string. + imx290llr is the mono version of the sensor. properties: compatible: enum: - sony,imx290 + - sony,imx290lqr + - sony,imx290llr reg: maxItems: 1 From patchwork Fri Feb 3 19:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 650480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93C5BC636CC for ; Fri, 3 Feb 2023 19:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233098AbjBCTR1 (ORCPT ); Fri, 3 Feb 2023 14:17:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233393AbjBCTRZ (ORCPT ); Fri, 3 Feb 2023 14:17:25 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 009886DFF5 for ; Fri, 3 Feb 2023 11:17:23 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id u10so1570139wmj.3 for ; Fri, 03 Feb 2023 11:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=W5entlBeyDhRDGltKJxqFOfBJjrmU0H4Re7/v+cZlz0=; b=bFMwNvY5BTbZXG89L5M/N5mKDpyZqPMmAGILfSGkm/MC69/UDeSwNRBYkGMsnoVXIF mL2rY1DeCzyZzjzDJSBFliI58lrMUfOuUSlK5n7sjKRZb3KhOyB/y5zmnGU1GzRnFKcF Lh9dPfKygkNcM+RrQdjY4tjDGSCRaFWf4o/KOqMzwCxiUtrjpIutcMnEVQfy75bPFqEY vEswv1s2uw+gt5S96R/rhJ6a9onebOqVnDOX4d94+Z2Nd/ahU6D/cYitDpfDMvCcc4Qe V7fi7UJqWBKXgyZE3u/ZNE+JC1pP0Pz36Yrk5URB/PJkgfesWpM5tMvqG39MriVyvwaw yIdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=W5entlBeyDhRDGltKJxqFOfBJjrmU0H4Re7/v+cZlz0=; b=TqF3DagBsUjzErhI0xVEHXdOUumKIa1ei6nsUPrVOKHKNENG1SBV6Ik9eANxmHpJl/ /2MJXx5C9NDHzkm2pN4/cuzosAzy4QUvzPv/LPNjZ93KylCFr6FzfoTAJhwFB3TgXn62 ZOOazn8/Na3vIM+rZlAFgry/DP+CnOEQpk9xYxeZLSsclTeNTxHgFLeH0PYj/ps2oxb2 GRGLHyAE0kcUfdOmkzPv0RI9QeZ9NK0mFoaaDUGZDSSLA5cQSro7sgRvM4dZQkc3UYq2 2gXMkuJpg4h1Qg8StGLzFgQ7bA9uq7/7TFK0OZ1BuN1FaNxwYAmHJipmcLb+eqkfHVYH iWnA== X-Gm-Message-State: AO0yUKUaHqLb/WqqpaYzSjvo2kijwcWV4bZKxaFRf+IHkvlg6hJN0UIT eUASmLEfh5beCgkA+aXOIMZL4g== X-Google-Smtp-Source: AK7set+dT0cb2jw45xZ17CqDfx0w+H72fJdBhyeW7AevJVtzVhG0FNt7EQVwDBg/cLuSyowO6c5DKw== X-Received: by 2002:a7b:ce97:0:b0:3dc:4cb5:41c with SMTP id q23-20020a7bce97000000b003dc4cb5041cmr10711741wmj.0.1675451842552; Fri, 03 Feb 2023 11:17:22 -0800 (PST) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id l20-20020a05600c089400b003dc41a9836esm3349263wmp.43.2023.02.03.11.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:17:21 -0800 (PST) From: Dave Stevenson To: Manivannan Sadhasivam , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Alexander Stein Cc: Dave Stevenson Subject: [PATCH v2 2/2] media: i2c: imx290: Add support for the mono sensor variant. Date: Fri, 3 Feb 2023 19:16:44 +0000 Message-Id: <20230203191644.947643-3-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203191644.947643-1-dave.stevenson@raspberrypi.com> References: <20230203191644.947643-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The IMX290 module is available as either mono or colour (Bayer). Update the driver so that it can advertise the correct mono formats instead of the colour ones. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx290.c | 81 ++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 49d6c8bdec41..9ce839541926 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -157,6 +158,21 @@ #define IMX290_NUM_SUPPLIES 3 +enum imx290_colour_variant { + IMX290_VARIANT_COLOUR, + IMX290_VARIANT_MONO, + IMX290_VARIANT_MAX +}; + +enum imx290_model { + IMX290_MODEL_IMX290LQR, + IMX290_MODEL_IMX290LLR, +}; + +struct imx290_model_info { + enum imx290_colour_variant colour_variant; +}; + struct imx290_regval { u32 reg; u32 val; @@ -177,6 +193,7 @@ struct imx290 { struct clk *xclk; struct regmap *regmap; u8 nlanes; + const struct imx290_model_info *model; struct v4l2_subdev sd; struct media_pad pad; @@ -414,7 +431,7 @@ static inline int imx290_modes_num(const struct imx290 *imx290) } struct imx290_format_info { - u32 code; + u32 code[IMX290_VARIANT_MAX]; u8 bpp; const struct imx290_regval *regs; unsigned int num_regs; @@ -422,26 +439,33 @@ struct imx290_format_info { static const struct imx290_format_info imx290_formats[] = { { - .code = MEDIA_BUS_FMT_SRGGB10_1X10, + .code = { + [IMX290_VARIANT_COLOUR] = MEDIA_BUS_FMT_SRGGB10_1X10, + [IMX290_VARIANT_MONO] = MEDIA_BUS_FMT_Y10_1X10 + }, .bpp = 10, .regs = imx290_10bit_settings, .num_regs = ARRAY_SIZE(imx290_10bit_settings), }, { - .code = MEDIA_BUS_FMT_SRGGB12_1X12, + .code = { + [IMX290_VARIANT_COLOUR] = MEDIA_BUS_FMT_SRGGB12_1X12, + [IMX290_VARIANT_MONO] = MEDIA_BUS_FMT_Y12_1X12 + }, .bpp = 12, .regs = imx290_12bit_settings, .num_regs = ARRAY_SIZE(imx290_12bit_settings), } }; -static const struct imx290_format_info *imx290_format_info(u32 code) +static const struct imx290_format_info * +imx290_format_info(const struct imx290 *imx290, u32 code) { unsigned int i; for (i = 0; i < ARRAY_SIZE(imx290_formats); ++i) { const struct imx290_format_info *info = &imx290_formats[i]; - if (info->code == code) + if (info->code[imx290->model->colour_variant] == code) return info; } @@ -536,7 +560,7 @@ static int imx290_set_black_level(struct imx290 *imx290, const struct v4l2_mbus_framefmt *format, unsigned int black_level, int *err) { - unsigned int bpp = imx290_format_info(format->code)->bpp; + unsigned int bpp = imx290_format_info(imx290, format->code)->bpp; return imx290_write(imx290, IMX290_BLKLEVEL, black_level >> (16 - bpp), err); @@ -548,7 +572,7 @@ static int imx290_setup_format(struct imx290 *imx290, const struct imx290_format_info *info; int ret; - info = imx290_format_info(format->code); + info = imx290_format_info(imx290, format->code); ret = imx290_set_register_array(imx290, info->regs, info->num_regs); if (ret < 0) { @@ -844,10 +868,12 @@ static int imx290_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { + const struct imx290 *imx290 = to_imx290(sd); + if (code->index >= ARRAY_SIZE(imx290_formats)) return -EINVAL; - code->code = imx290_formats[code->index].code; + code->code = imx290_formats[code->index].code[imx290->model->colour_variant]; return 0; } @@ -859,7 +885,7 @@ static int imx290_enum_frame_size(struct v4l2_subdev *sd, const struct imx290 *imx290 = to_imx290(sd); const struct imx290_mode *imx290_modes = imx290_modes_ptr(imx290); - if (!imx290_format_info(fse->code)) + if (!imx290_format_info(imx290, fse->code)) return -EINVAL; if (fse->index >= imx290_modes_num(imx290)) @@ -888,8 +914,8 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, fmt->format.width = mode->width; fmt->format.height = mode->height; - if (!imx290_format_info(fmt->format.code)) - fmt->format.code = imx290_formats[0].code; + if (!imx290_format_info(imx290, fmt->format.code)) + fmt->format.code = imx290_formats[0].code[imx290->model->colour_variant]; fmt->format.field = V4L2_FIELD_NONE; @@ -1177,6 +1203,31 @@ static s64 imx290_check_link_freqs(const struct imx290 *imx290, return 0; } +static const struct imx290_model_info imx290_models[] = { + [IMX290_MODEL_IMX290LQR] = { + .colour_variant = IMX290_VARIANT_COLOUR, + }, + [IMX290_MODEL_IMX290LLR] = { + .colour_variant = IMX290_VARIANT_MONO, + }, +}; + +static const struct of_device_id imx290_of_match[] = { + { + /* Deprecated - synonym for "sony,imx290lqr" */ + .compatible = "sony,imx290", + .data = &imx290_models[IMX290_MODEL_IMX290LQR], + }, { + .compatible = "sony,imx290lqr", + .data = &imx290_models[IMX290_MODEL_IMX290LQR], + }, { + .compatible = "sony,imx290llr", + .data = &imx290_models[IMX290_MODEL_IMX290LLR], + }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, imx290_of_match); + static int imx290_parse_dt(struct imx290 *imx290) { /* Only CSI2 is supported for now: */ @@ -1187,6 +1238,8 @@ static int imx290_parse_dt(struct imx290 *imx290) int ret; s64 fq; + imx290->model = (const struct imx290_model_info *)of_device_get_match_data(imx290->dev); + endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(imx290->dev), NULL); if (!endpoint) { dev_err(imx290->dev, "Endpoint node not found\n"); @@ -1351,12 +1404,6 @@ static void imx290_remove(struct i2c_client *client) pm_runtime_set_suspended(imx290->dev); } -static const struct of_device_id imx290_of_match[] = { - { .compatible = "sony,imx290" }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, imx290_of_match); - static struct i2c_driver imx290_i2c_driver = { .probe_new = imx290_probe, .remove = imx290_remove,