From patchwork Mon Oct 9 13:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857454vqo; Mon, 9 Oct 2023 06:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpaqeCk5IzUS//+amhesje0BxoL65EJEEeWvxG8eqBnXdYzT9yzTCYE2kRUELXBgr2M3Wx X-Received: by 2002:a17:902:e881:b0:1c4:4c10:6ae3 with SMTP id w1-20020a170902e88100b001c44c106ae3mr17433546plg.23.1696857096332; Mon, 09 Oct 2023 06:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857096; cv=none; d=google.com; s=arc-20160816; b=AWbosL8BahasQl9Q3tAkG9JXS4kyRGBU6AR+uAU+4l3BPuszW8CvLg9vLz9876laQr zpBKkumOsYsCuMJUkMuKotjQ2kNUGPvwFx5+j7jDaDSM2HK9VADDVNLZxuS7l+rPwJeg y86ghzFTkumAWJeMqIY7w36qqMPpnOef8Nloe6NHF3WK6yv/DpVD29HoZ95OYZnpXjsC ODPGxUJjewbG90ztboP7nzuLTeTLNw5PDfr0Sh0JKMblbGqDcWplFVwCaNswrLHYsuxc HerAQjHa6A5OFtTYvn9JrPeqla68F2gxamOsbU8641cAHg1+82ECMjmbCzZBJn6CfIPs JCLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Lz2x3xIw/kJkOKbJx/niYJH/N0ewRr5xZQck2iUm7x0=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=GhsyUbZBfU/Wwee50HAhdotvl3+bK4hl4nS9IEg6OvgK5sngkBp63bTAja2FhuHBMr +ktIuM7TBkY+eQ9QBm9pp+m7a2fo1ZQbB5hGPeL1/GRheY5PWMA6OcTz4OaJAoeZkce6 CJIcmSv/muWXYkJsGZySsX6g6UcMzt8zQ+JLOXua7caHmXWhhblbZuH21vq21RbAUBzy RbRM8ygUYoLIiX1HzJxlJJ5K4SNYZqPKIBJseYPeeeeUA5tq7InZnp1clIwsspL536FB Yf5Mw9gTg4QYrXzk4KKagN0Pt8mOLN6r1uk3R/feqtgbqSqnxYEqb1uoF3sE2KIScJN2 sqvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B7zVxk8H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l10-20020a170903244a00b001c58401354dsi4540113pls.565.2023.10.09.06.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B7zVxk8H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D7AD9807ED95; Mon, 9 Oct 2023 06:10:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376619AbjJINKE (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376781AbjJINKB (ORCPT ); Mon, 9 Oct 2023 09:10:01 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B6793; Mon, 9 Oct 2023 06:09:58 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9hMt055512; Mon, 9 Oct 2023 08:09:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856983; bh=Lz2x3xIw/kJkOKbJx/niYJH/N0ewRr5xZQck2iUm7x0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B7zVxk8H83ezeoHAY3h34LXQOTdmhymSr2IzCbeW+R+Z4/CRGGnzJaA2zAiXTvizL iHWwetwRcEKd5TsYNIMUCLBU+lzOER2+CZIpBncTSuKFPTJ/pNgiHmB5nFs9LtVRVB Vvtzlunpa3y5b5kZXQmDM2k3OwvbWyuNWbNHjpQY= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9hAD076964 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:43 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:43 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:42 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9gd0055488; Mon, 9 Oct 2023 08:09:42 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 01/13] media: dt-bindings: Make sure items in data-lanes are unique Date: Mon, 9 Oct 2023 18:39:27 +0530 Message-ID: <20231009-upstream_csi-v10-1-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1388; i=j-luthra@ti.com; h=from:subject:message-id; bh=OCxVyiBNv/iKEBoQi4+IK0XyQm++LE8DE/EIGdFNE6Q=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/slBKH+PkDCYAQAJv4U95j33kYS7kF8cIYg6 bVOJONCs3OJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7JQAKCRBD3pH5JJpx RSe3EACMzIvgxPmloW2hDwypwO0Yexi5djPKJq0LRH/Zv+4tycwi3VmARg/n77w+HnFKOXlG0Vo 6xEPIxMPrJazPQDEuw0y7UOfeIx0OGIxE5nH6ul4x4ZAiofrA5gjJtPPlJ7tC0Of7R49BtomHeS V/sC1xqjEe7/j22AAmwmBwIYBDWR2425ahfK2lYgNHZ+PI69rQgXjgWouIBFrIiIrQGF5/9++fN 3HVJJJSkwZ54WC+hZDWFistPIPWxtf1q8zyHg1wTRgl5tAmv5hQFUlGv22xEiCtQ1biiwP/77jw gHBz7yv5/Y3hBS2QsCxhOY+P/TY4ddJruSJYGoODYxZxak89apPCx61iutEtNaEQ+NqOSiPw7iy SL7a/VS70w//H/2pVy0kPuSsHkYMvqcB7R7cQc/vwuEPMK/5IW9AlKLbz1yeOuuI85Jdc7GQA1S mUfsNdEl6kH5bsDfKX4M5fuFdStA8UQpTY8arTu6Or6+V4xN6tUcHzGwfrTdG7lmPCVU+jreSmO 9me4lE9eIDyiq6YWo1IuugERZBkS0AB8vqHqB/jF/szrzCBzv37jQ3+AAcEEg8NCtF4LJcj967t vFZ9WB8BhqIUJpCMrqhk5U98WI8PvUGU+Wa3+krJ4D9/Rl/54e/4HyGmoEEFFePLgUs/B0YaOGl 6j+UBfcVteci6/g== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:10:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283626746353657 X-GMAIL-MSGID: 1779283626746353657 From: Pratyush Yadav The data-lanes property maps the logical lane numbers to the physical lane numbers. The position of an entry is the logical lane number and its value is the physical lane number. Since one physical lane can only map to one logical lane, no number in the list should repeat. Add the uniqueItems constraint on the property to enforce this. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Acked-by: Rob Herring Signed-off-by: Jai Luthra --- Documentation/devicetree/bindings/media/video-interfaces.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/media/video-interfaces.yaml b/Documentation/devicetree/bindings/media/video-interfaces.yaml index a211d49dc2ac..26e3e7d7c67b 100644 --- a/Documentation/devicetree/bindings/media/video-interfaces.yaml +++ b/Documentation/devicetree/bindings/media/video-interfaces.yaml @@ -160,6 +160,7 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32-array minItems: 1 maxItems: 8 + uniqueItems: true items: # Assume up to 9 physical lane indices maximum: 8 From patchwork Mon Oct 9 13:09:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857456vqo; Mon, 9 Oct 2023 06:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHVL97VBKfaDkbGw2B8SW2F9oFKqvRrWlTRkRsa4sPf/WZYrZho/V7grkSbOf8uGOYvpX1 X-Received: by 2002:a05:6a21:3294:b0:16b:8572:5a4a with SMTP id yt20-20020a056a21329400b0016b85725a4amr8245295pzb.61.1696857096479; Mon, 09 Oct 2023 06:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857096; cv=none; d=google.com; s=arc-20160816; b=geJ82sAjd64w0Os14DQqNzwg6EXk0oz8iqiLWkU8wmyBWgrICBjsuoi0F1lq1jR3A0 TebOIh9dl15v31RJUEYuxvCqWj06cPCPdD4lIv8Dq+tlLZqgjMmIv8CJ3Og3tvb7CDhf ejUfGhTCOV6059Kr7pkGrq1IHQ0yiMG9WXbHSTOESxCk4+HJFviPIUXslnewATywu6/z uMIEc1ux6F+euBEKN4N87h7UB33UPTqprCQTmtErnx9WhWBjxXRjqUcD3XrUWnm/5hRQ lOB3HCCqqj7wjd+i6kvKJ8ITSXjb1UjIkO8CjH2N/Rz6zEoMPWpZj+xIT24yU3TO4X1k xPGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BgxjJaKkhypgGTDotppIbabHhDLsyOxiD/tKF7b/5FI=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=ToiUBasrnMCsE6vyepF+yO/iyycsT05VhjRZwiCEDF4s5kNWtCBn4GQkRO56Wk++bl KYJRoEcK+nDaruo7m6rwcLstSJQ/MPmTicVqoZUN7MeeezzaCB/zzp1bkikKWKSlelvX 4fMMunOm3GW+yXwowBRUUY/2r8WwXzCCdub6ZApyNCY/XAbf9CGoSeeib0zkG4WvG5ck GFj15WuZunF63pQPJfeza+A7MCvDVA81OxXfV4YixeyUYQT1AJaEcyJxM0VkkT5KbSFE eHdpdhfDQHuwLavLrl4Omzi49vvSCtwb3lLPOT9zBVaTKHy9R3iQ8km3FhxCCJVU8GuU zF4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="ZqW54PP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q3-20020a056a00150300b00690f8edee16si7470186pfu.275.2023.10.09.06.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="ZqW54PP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E8C2680BD52E; Mon, 9 Oct 2023 06:10:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376856AbjJINKV (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376780AbjJINKE (ORCPT ); Mon, 9 Oct 2023 09:10:04 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952FABA; Mon, 9 Oct 2023 06:10:02 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9iBd043923; Mon, 9 Oct 2023 08:09:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856984; bh=BgxjJaKkhypgGTDotppIbabHhDLsyOxiD/tKF7b/5FI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZqW54PP/AxS+p73SATwC9HUEgdTUUhWoBKhYUyzEjt12mijfuSVAdPB3iUNe6pIct 18E9IVDZ1EN3lek2sgg4TIT7sBAkRsWvXI7Yy7yeWXcddxfK2SMqQTktp7rVl7mSx7 qkO46RFBtOUdxPLsuSVCO+vBHuHZEJJW0SknWbbM= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9i7R076972 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:44 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:44 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:44 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9hPS117909; Mon, 9 Oct 2023 08:09:44 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 02/13] media: dt-bindings: cadence-csi2rx: Add TI compatible string Date: Mon, 9 Oct 2023 18:39:28 +0530 Message-ID: <20231009-upstream_csi-v10-2-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=970; i=j-luthra@ti.com; h=from:subject:message-id; bh=yrzgWB6pzGmHW+FN3ZDQrdA1db60oGi+PIM018sEEvc=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/smnhGLhA7u9h02i3/0Kd8QycjSAZBnEvf7V PPfSv3v3s+JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7JgAKCRBD3pH5JJpx Rb5vD/9cHjnkUGH6ekQ9asA/a8pWobsNyak08z5s0JHR1M/dAGkWrqTvrQpK0o7tKRbPfUu/tkZ uZnCk1KMH+cy/K6kQXlJi6+QO8oFkdjsSPrXpo9/zXFpdwPKjzR4n+pPxHPxpAe5v7aGw/RMMlM M2RHMeejKY0UOwfFe8OSy3/GW/tqRKRz4KAfJwAJxA2QoOuBlXlxjovgpbGLCoZ8gPRM4SxAJDo BjRE6XHYo6PTdm6XL/YqXDuGUIUWZcDTeGZebV1To++Mr3BBdlPbnA80KGm+nW+3ps76XBqk38L hlAEMdgpGwVLh0Q7zSGUk2Ph2ghqM3LJnS096+sjjsTUIzAgcWCBBmmUhjc4c1l/HPYpMWBFOnU TZg31qnFf3tcX07pGKVl36xPPrX7iAcBINDpITyHjMiywVn4ZfOaoxzJ//99ZnAuNFqExcZ8vqv +UG4LdlaA3jWKr/LnTkcBkYVUOOjUTa91T5bRdOwk1b0pzN9IHyVvwpq1f+GdW+nttLhKCclJxv uIHmbEx7K5TZqlsABoALdPb2ymZhYdI90LY5YWSykFUb+oP8tx56I9fnnvqaDuvt1BSLJHU/Kca JPf5VXC+JJSq+mHTQMOWMUs4KHOswEiHPtDVLArh8jCz5vjfTHU2D+mVFFNQAvyFrJKFRfnRigj EhCIzy3U5aQEzTA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:10:54 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283627012956195 X-GMAIL-MSGID: 1779283627012956195 Add a SoC-specific compatible string for TI's integration of this IP in J7 and AM62 line of SoCs. Tested-by: Julien Massot Reviewed-by: Maxime Ripard Reviewed-by: Laurent Pinchart Acked-by: Krzysztof Kozlowski Signed-off-by: Jai Luthra --- Documentation/devicetree/bindings/media/cdns,csi2rx.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/media/cdns,csi2rx.yaml b/Documentation/devicetree/bindings/media/cdns,csi2rx.yaml index 30a335b10762..2008a47c0580 100644 --- a/Documentation/devicetree/bindings/media/cdns,csi2rx.yaml +++ b/Documentation/devicetree/bindings/media/cdns,csi2rx.yaml @@ -18,6 +18,7 @@ properties: items: - enum: - starfive,jh7110-csi2rx + - ti,j721e-csi2rx - const: cdns,csi2rx reg: From patchwork Mon Oct 9 13:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857230vqo; Mon, 9 Oct 2023 06:11:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGasRxVllPS9/+Pe3N3pjrM60fB18iuVxLMpIhajWAcJt1gxmKLtzByIDTTEGJj9KIbNTtJ X-Received: by 2002:a17:902:7207:b0:1bd:ca80:6fe6 with SMTP id ba7-20020a170902720700b001bdca806fe6mr11343141plb.41.1696857077094; Mon, 09 Oct 2023 06:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857077; cv=none; d=google.com; s=arc-20160816; b=FZk5u9Go9pKLrRd4MjQXgjGvzCDA92iFTtY9+5ASvCqMYbtl2tApfVf8g7pk2NIxGc vT0SLk+KeXU/x8Mxnn7gatoUITigFk5Vu5tCX8+mBmm1UILseAFqJL7TUmamKq/TivNB GF5J3KkyLNIPRPJFnqazl9QrWzNoa0yRyWleYMcfVOqCwxg6EZXCYQO9gkWUpIkITpqt 9DqUnNKnRBHpBcc77915NADqyg2E7vbVrz9DOFuplSY8G6fJr0ntwYcLzuadvucPpKLp qOksKkhajk791CKzADoVKzyjGPvv4oEC97/MP79FNR9g374jaEKdpjWxkMDXsRnRfSKD bS/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4FfPwCB/CMrbMGKnvI3/6dyXUCw/bzYzkHRahhDgvUM=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=Azc+jSkfoMkDs48o/UBhgdr0i105UnyDa8OnNWK0wnrNEYU6T2MQAflISd/OfvyBzJ 1vfThEuW7F1+4zZCXzXUuDDMaVtYt1A0YWbP/mUeUgBJ7P+2U/VX6Gww96D0Mht3/0sv yMCof1fR+x9DWyP8ujITqbfYz3NaP7IbUF3SijDZ71dcByLKdttPW71KjO/Rm4AVS823 H9o9MbU/L0exp6bZkqIC/CE9zbhFSwjOEhliSrrLv/xA1UYyIvLHp0ppWcRHzyTICt6b Qw3ENjCIMTUstS4O0HUcL6XJJuB7tv9Evou1q4yg0omLpdcJAjIudd0QLqXV+MjKzlsJ rU3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cjnPclDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b7-20020a170902650700b001c3ba275321si5799362plk.76.2023.10.09.06.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cjnPclDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 36BC28057E7B; Mon, 9 Oct 2023 06:10:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376774AbjJINKR (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376790AbjJINKF (ORCPT ); Mon, 9 Oct 2023 09:10:05 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE449C; Mon, 9 Oct 2023 06:10:03 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9khl043928; Mon, 9 Oct 2023 08:09:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856986; bh=4FfPwCB/CMrbMGKnvI3/6dyXUCw/bzYzkHRahhDgvUM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cjnPclDTIweoFDdjSZi1ghXD2LOHszCdfNHOiHixZI6mIuSlEgfTqOmDpMiNumqGA r5k51QzkPQ21usrkTIikU4Lcfa4tfLDHrrzAkyA33ELrFaxvTpfv6LWFQylz3sOuIy hf4CsfAUIb8/MxPLChlAv/DJDxoLibPMTpks+AO0= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9kNg076979 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:46 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:45 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:45 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9jx9007173; Mon, 9 Oct 2023 08:09:45 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 03/13] media: cadence: csi2rx: Unregister v4l2 async notifier Date: Mon, 9 Oct 2023 18:39:29 +0530 Message-ID: <20231009-upstream_csi-v10-3-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2122; i=j-luthra@ti.com; h=from:subject:message-id; bh=1dJfXJfqhjtT9EYR9IVfaCzIQ6DWNfmI/vFzK18yFgs=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/snGI5M5/tW7zk6T4eL361rRn+EcUxDcq+E2 ncHfr0MQ8iJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7JwAKCRBD3pH5JJpx RaAtD/0RsVBMopQMWLwpxU4C8iJlHiA3D85TWroerbK0b/kmdaOhEW4g/yybms+LFbDYJvGhBOa 1grZgBQT29piHIGWsMj51TSxwv0qTWNTNyEaa4zUptdvUtavo9uTT6E4uxmLY1IBtC3eZ6OAVTE 6H9URPB8cGEIfp3OjzuPB9mb9u+DQPZtjB0upaQZiyNafyoGA0hh5BJRIU4OGkPk2hq+0pN8eju hdXRM/Ue3Kx5DjTOA9McoVdgJtHwWaFJz+6I7un1LGAxPhuh6DfcNOXGoA/QA4ulhhdofOZXLFg bXGiqxFUBrfDgWxZuGyVuRBuoSio3hvIQBDqnBzbE53/ipsOlLuT1CnqFdHGkqUbHcua9kSG3UH LQ8Rn31ZAuJfAHKMwxcEd/+hhg01DGgk9N97vaaZ4VFmHvkLr9FyC4Qy7A0eoWQ2E27dO+GqcTw nrIy+ngmtftzufeSJ1/45fRm/pxLS60rWJrVirMcP7aL8tzVQFvFJ07pgoNj0gg2z/md2pyfPhT ZdFJxafMXQ6jncMetjx1P1+4M+IkTxOlfCGjmlQbxuHUD9iOndpJD78OSZC2WSuEOUGVoiI+IJO dYgVMYwY1LH8ejGuzLYfqXxSsl4wBjPMj8zzFz4Y2q6PVPy4/wNxdExdpeRisja2BH+x+ZCyEwm 0yh6qB7aiRFNb+Q== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:10:47 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283606417851067 X-GMAIL-MSGID: 1779283606417851067 From: Pratyush Yadav The notifier is added to the global notifier list when registered. When the module is removed, the struct csi2rx_priv in which the notifier is embedded, is destroyed. As a result the notifier list has a reference to a notifier that no longer exists. This causes invalid memory accesses when the list is iterated over. Similar for when the probe fails. Unregister and clean up the notifier to avoid this. Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver") Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index b9d9058e2ce3..64e472ca3594 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -479,8 +479,10 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) asd = v4l2_async_nf_add_fwnode_remote(&csi2rx->notifier, fwh, struct v4l2_async_connection); of_node_put(ep); - if (IS_ERR(asd)) + if (IS_ERR(asd)) { + v4l2_async_nf_cleanup(&csi2rx->notifier); return PTR_ERR(asd); + } csi2rx->notifier.ops = &csi2rx_notifier_ops; @@ -543,6 +545,7 @@ static int csi2rx_probe(struct platform_device *pdev) return 0; err_cleanup: + v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); err_free_priv: kfree(csi2rx); @@ -553,6 +556,8 @@ static void csi2rx_remove(struct platform_device *pdev) { struct csi2rx_priv *csi2rx = platform_get_drvdata(pdev); + v4l2_async_nf_unregister(&csi2rx->notifier); + v4l2_async_nf_cleanup(&csi2rx->notifier); v4l2_async_unregister_subdev(&csi2rx->subdev); kfree(csi2rx); } From patchwork Mon Oct 9 13:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857528vqo; Mon, 9 Oct 2023 06:11:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHduInx/tdq9d3qs//s3VXrXtWSp4+0SKg8kVeoOjTha+l+8luUEonpIDAO3/wfXbwWD47h X-Received: by 2002:a05:6a00:198f:b0:693:43b5:aaf3 with SMTP id d15-20020a056a00198f00b0069343b5aaf3mr18107031pfl.13.1696857102100; Mon, 09 Oct 2023 06:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857102; cv=none; d=google.com; s=arc-20160816; b=m/GLYnDLDHJUJJzbnCYeo8Ori9U0vpYYXasnrmpVd3nxx67DqvsLVR3rF+Ml2bSgL0 JBnM3cmAqnp+wADe1rPUSCrDEYyZ42aUlMrR/YGBu1rsRTeMXFwEF6YYpDhdrr0VlfHg nmKmjjFHvMYVwpZBiNp7W2gRLS/9x9iuKuaHh7VCT8po3VfBOVS4b4HVTJiV54JMLrEs 2PcXf/Hlg0DLRyQfR/9Nyo+AG2n9kicbuuCkRZ3tpW/PpSIaDKtxBuIEwzyxaxxJZ4OI qMKROmA0EgWVgh2TGm927NKr+S1xtNzlTDm5QSysNEmNirsMVm2+h6B5W2jJrtEaddvs 8sug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CV36wgcU/HLXBVGVMd9iVHL8DT1YkN+Xfgsfa3xX9x8=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=UyizyhsMaOQuQSSlTjTm/bX8J5l/wzgptGhQ02+YGAGtX0AomgFw5ZzEIiv+X4S5pN LTnt3LaCvdNDOTEKQNAlP9HZp0mbascwWzyE5T1mS2njQxKWtAVKNUBlVqkHT70hDb2O TKOPilP7F/Z6knkSz3NmEkm5LHwFEPwOfJTWvxBqWcQPln/oN8bdD7SrK7EXob4UhdzA IKht99iUZp79tQyfyy2zrAt3dN6pC4+8Dhf2p0f1BlxWLk1iY2s8XpuygjpWXP5gv3QW DHt/ctV51kxJNNCwyPPp9j6273YrxVT2jWnCMykMQroAy6oJu50sfuyYYOeEZzrk87XU bekg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=dgsaxSEc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h15-20020a65638f000000b005778df5647dsi9367001pgv.401.2023.10.09.06.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=dgsaxSEc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5C64780A73C6; Mon, 9 Oct 2023 06:11:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376830AbjJINKb (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376809AbjJINKL (ORCPT ); Mon, 9 Oct 2023 09:10:11 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5835DB6; Mon, 9 Oct 2023 06:10:08 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9lqO067927; Mon, 9 Oct 2023 08:09:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856987; bh=CV36wgcU/HLXBVGVMd9iVHL8DT1YkN+Xfgsfa3xX9x8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=dgsaxSEcdcpN2PjibxRa5+3ngC9mQETVpIYjtI+VVe9/jWrIPo+Lr0OwWLOOmvRqX EpDDo6fRYFV/QywxLGfk9wM0ONP4bs9ozsxAHcaJQdoc1QF95jZeg/u1JvJrEUh7pd WNDeLdofh2jANhlHyx3gVuz0HGfcXPCa7N5Q8dAI= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9lq9071516 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:47 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:47 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:47 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9kYZ007220; Mon, 9 Oct 2023 08:09:47 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 04/13] media: cadence: csi2rx: Cleanup media entity properly Date: Mon, 9 Oct 2023 18:39:30 +0530 Message-ID: <20231009-upstream_csi-v10-4-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1450; i=j-luthra@ti.com; h=from:subject:message-id; bh=H/tqA+nD3NGE1eGbYGM3sFZkNgmvZBDs5F3fkDcglS8=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/soM+r1Abx3POL55vGgtgNp8ipGOuaEErKcS St/el2ZgeeJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7KAAKCRBD3pH5JJpx RQiWD/0Vi/7XZI+N67WWGCQ2/h8GgvfJLjRiLzj0TTUoBt1A6QgXcZD7scqg31TGrTbrIHPAvx8 rHnaz6ZKE/1p9BxitVGsgVuIxEsXlZSspJA3lsGiHOCvnxkiFkrLLO68iYqcjdAcr2tvfOjrZye HmZW25ueDRVmFpRlfqvP5JLvMHCX6h1QKncIO0ZileirmvVsKC1bbpFz7LdVGE1uOIiH2v5o/WK hupzvamqUp6f1c0+3QgaIUxetYw9hr39tQNh2svBCpgbtwHPxyYPYwE7l2woM92WaWjw3JVBm5/ wcFMdAToIGgqCVIxXUouEUrxjPhkJxyfO3f55LoidBnEsV4yT8whrjNf2YFTpfiakk+zt0mT3cR JGQS4vRVUw3E0ss6l/PIk83iHRmSlcXj4k3xzTJ8t1s0wyA0Cjd3cbkXSaOTRibhAskP3h3iBNW VZUilDN62HRBEKDYfLLRm6C0tdSgzwjHKxD4D0vkl7QGqRH5QKCy38UW/n21cx9TR5k3qSrgjrp ZP57OQkacsQlqJsAXf/ebltO4mvPZyWJz35/HM6T43Ixjz90SNv0zR4GrsGcUsoxONRjScw0UeD e/I5eBEexLppIqhII1F0tm0JgvoarWnGiJN4Aw760Rfr6mhtc0BIfaRC9vD9uvvcVKTfL9hcMIn subRbnDwSZS9pvQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283632799637997 X-GMAIL-MSGID: 1779283632799637997 From: Pratyush Yadav Call media_entity_cleanup() in probe error path and remove to make sure the media entity is cleaned up properly. Suggested-by: Laurent Pinchart Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 64e472ca3594..399b2f800dc4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -547,6 +547,7 @@ static int csi2rx_probe(struct platform_device *pdev) err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); + media_entity_cleanup(&csi2rx->subdev.entity); err_free_priv: kfree(csi2rx); return ret; @@ -559,6 +560,7 @@ static void csi2rx_remove(struct platform_device *pdev) v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); v4l2_async_unregister_subdev(&csi2rx->subdev); + media_entity_cleanup(&csi2rx->subdev.entity); kfree(csi2rx); } From patchwork Mon Oct 9 13:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857470vqo; Mon, 9 Oct 2023 06:11:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgvB6VRD72d8vIQzHY9E1nNVdSkDPb0ZLnu4lddkkXqjnqB/nJyBBXXsiWQ/awTRIblWWK X-Received: by 2002:a17:902:ea0c:b0:1c6:3157:29f3 with SMTP id s12-20020a170902ea0c00b001c6315729f3mr15285092plg.36.1696857097515; Mon, 09 Oct 2023 06:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857097; cv=none; d=google.com; s=arc-20160816; b=Ju/iH55kQSrzwo1AD3gWWcGlCDIXGF15/JRgBaACRl8Ve2jYRp/KFSVq+87ZgS4Hf4 WunhTTAfwRVYRgOQ3XXJazMyaLL6PSikfntWDQd2CZxPSnWZld95CeNmN9OYYQCv/cze wZ4ECAd2NKtvknN9Q8CV0R4a4vpNHzrvxUeixvysQO7dWbwj9U+1tSmOa9ACJP3RmB2b 165swbKz1vv7uj8CghnardQcjRb4MbRdUtEej9OyplttjBSjWkuZXPv/ctFt9TkveAJq JCmV6Du+ofJGT+L57PTLlehR3qSZAiyyo03Bva7AxADuIEeNREsYzFKOVYJLA+/vn8sY OMww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bGpb3GLN/T4dyh3nBcjV+qVV/RdD272uzDzrTHNjjwE=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=lH92DALHJgatapFwSOhjMYnij+uZBXQ+ezTGpdXjB51QJHAC6mSX2xSxQFyKTZZPZ/ 4UcOuWh3UvnIudEUwdec4ajKryAc8bOCDdNLJCUbvOAdtTF4oJ6UVATmKBp9inaTkBz8 DX9z0imncObRuMUwT7zsBOaewkKcK6M8SP7+V/FehF7fyH9oh4gWeV4jeKEadKyNvsqx t5biZc8IbvSxQUQLuppAHQ4lI5xP2Kh/PDyNIGVvgd5orP1rpg1CIaWeIwJX/a3F9F8O G+oUTF+u/itWuHLN76Gbzz1a3Ul3VuVcezezm4Kpq1m8p1he3mBOC5+n5XZpgmHp03Tg t6AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="dl/Ioopd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s5-20020a170903200500b001c88fd958ecsi6917477pla.110.2023.10.09.06.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="dl/Ioopd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7754D807799B; Mon, 9 Oct 2023 06:10:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376800AbjJINKJ (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376710AbjJINKD (ORCPT ); Mon, 9 Oct 2023 09:10:03 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C92B6; Mon, 9 Oct 2023 06:10:01 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9nCW055525; Mon, 9 Oct 2023 08:09:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856989; bh=bGpb3GLN/T4dyh3nBcjV+qVV/RdD272uzDzrTHNjjwE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=dl/Ioopdtg9WMkVDWs+Cfy4PUT16w9RnRKTCWRdhfPIt/XRS6iie1BXDF1Q6NC6Fu 7eCYQ1DF9lPQZpfHoaREY93giMqR/8MjcHeFiB/qrQZKX/wPkXaibjITWwCsNOKEUf 5hCYyjmqgIQyUH+/Syt0mrqj+aDfyHRKN7mBWz88= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9nat014508 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:49 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:49 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:49 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9mho117965; Mon, 9 Oct 2023 08:09:48 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 05/13] media: cadence: csi2rx: Add get_fmt and set_fmt pad ops Date: Mon, 9 Oct 2023 18:39:31 +0530 Message-ID: <20231009-upstream_csi-v10-5-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5517; i=j-luthra@ti.com; h=from:subject:message-id; bh=5t1qq9VUbX4/94lsj2wyTmgoRSNIADX7Km2mBA5J5xg=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sp4pcyzfDa11JqnxFJADGerfjALIggwbqdU GYowoyIBVWJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7KQAKCRBD3pH5JJpx RbxbEACDhnX++uR9OkD5TCEHwglqAdls0JD6287seW81r1yg78Zi91aFAO3lUkhlMNE0XK52EL9 yvPF1dg0urNMKhfN9of+K+EGoPx1+5n85Nm4fNxSk1VPK1lHk3NQgYrlT3hf+hMVwHcOs/FgtQ0 dE5IUedCvxOpx6huEn5WTQNi5cd/qlyq+JYlOj3EXJmZuuL8dkTE9jl/lzSXkOnguBBU2SHYhKG AUd0SaGoD4IDz9y0eja6NFO1lH8VlYXBAvuZHi+FfggjRg8mgJcIJ8kjuNO6seXLbnE+WOY4Cd5 SEZLVqS2slJ9CznjN6eXEsTzLwLBaoSY/yJjM+BhQNyp2iDPRiIsXajdEtYgJdRlbG3grW8CLND GdGRpqTpcxzsiHJ61RxIWytuk+Q/585znCjyb60m8LqPCqXSSy+48sRLkdzofHELWiM6Jh202Gn +guJhHSDTl4tCEZpbJ3iZBFg+OUJS5VbusUMZj5eticHYTOywYAkR2fCxverRJveoUeh3xAOAge fegneLujgKSOAJ+gFeMjHKw1Jvhk4a4SUEaNSJb9qsUsPYjIwGlojf3TpDoowacjox4JrkhyJJm 24qYQGIyOImTt+jibY/e5YfuVoJCjzbB231t9Fot8M2iKGrJ9IBe+jUMnQRKVs9d0WrTpu/iKK+ LGU5zhxi85yEdQQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:10:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283627825438550 X-GMAIL-MSGID: 1779283627825438550 From: Pratyush Yadav The format is needed to calculate the link speed for the external DPHY configuration. It is not right to query the format from the source subdev. Add get_fmt and set_fmt pad operations so that the format can be configured and correct bpp be selected. Initialize and use the v4l2 subdev active state to keep track of the active formats. Also propagate the new format from the sink pad to all the source pads. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Maxime Ripard Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra --- Changes in v10: - Remove redundant checks in set_fmt() as we ensure pad is SINK drivers/media/platform/cadence/cdns-csi2rx.c | 96 +++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 399b2f800dc4..f9b41451f4a4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -61,6 +61,11 @@ enum csi2rx_pads { CSI2RX_PAD_MAX, }; +struct csi2rx_fmt { + u32 code; + u8 bpp; +}; + struct csi2rx_priv { struct device *dev; unsigned int count; @@ -95,6 +100,32 @@ struct csi2rx_priv { int source_pad; }; +static const struct csi2rx_fmt formats[] = { + { .code = MEDIA_BUS_FMT_YUYV8_1X16, .bpp = 16, }, + { .code = MEDIA_BUS_FMT_UYVY8_1X16, .bpp = 16, }, + { .code = MEDIA_BUS_FMT_YVYU8_1X16, .bpp = 16, }, + { .code = MEDIA_BUS_FMT_VYUY8_1X16, .bpp = 16, }, + { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, }, + { .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, }, + { .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, }, + { .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, }, + { .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, }, +}; + +static const struct csi2rx_fmt *csi2rx_get_fmt_by_code(u32 code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(formats); i++) + if (formats[i].code == code) + return &formats[i]; + + return NULL; +} + static inline struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev) { @@ -303,12 +334,68 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) return ret; } +static int csi2rx_set_fmt(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt; + unsigned int i; + + /* No transcoding, source and sink formats must match. */ + if (format->pad != CSI2RX_PAD_SINK) + return v4l2_subdev_get_fmt(subdev, state, format); + + if (!csi2rx_get_fmt_by_code(format->format.code)) + format->format.code = formats[0].code; + + format->format.field = V4L2_FIELD_NONE; + + /* Set sink format */ + fmt = v4l2_subdev_get_pad_format(subdev, state, format->pad); + *fmt = format->format; + + /* Propagate to source formats */ + for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) { + fmt = v4l2_subdev_get_pad_format(subdev, state, i); + *fmt = format->format; + } + + return 0; +} + +static int csi2rx_init_cfg(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state) +{ + struct v4l2_subdev_format format = { + .pad = CSI2RX_PAD_SINK, + .format = { + .width = 640, + .height = 480, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .field = V4L2_FIELD_NONE, + .colorspace = V4L2_COLORSPACE_SRGB, + .ycbcr_enc = V4L2_YCBCR_ENC_601, + .quantization = V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func = V4L2_XFER_FUNC_SRGB, + }, + }; + + return csi2rx_set_fmt(subdev, state, &format); +} + +static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = { + .get_fmt = v4l2_subdev_get_fmt, + .set_fmt = csi2rx_set_fmt, + .init_cfg = csi2rx_init_cfg, +}; + static const struct v4l2_subdev_video_ops csi2rx_video_ops = { .s_stream = csi2rx_s_stream, }; static const struct v4l2_subdev_ops csi2rx_subdev_ops = { .video = &csi2rx_video_ops, + .pad = &csi2rx_pad_ops, }; static int csi2rx_async_bound(struct v4l2_async_notifier *notifier, @@ -532,9 +619,13 @@ static int csi2rx_probe(struct platform_device *pdev) if (ret) goto err_cleanup; + ret = v4l2_subdev_init_finalize(&csi2rx->subdev); + if (ret) + goto err_cleanup; + ret = v4l2_async_register_subdev(&csi2rx->subdev); if (ret < 0) - goto err_cleanup; + goto err_free_state; dev_info(&pdev->dev, "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n", @@ -544,6 +635,8 @@ static int csi2rx_probe(struct platform_device *pdev) return 0; +err_free_state: + v4l2_subdev_cleanup(&csi2rx->subdev); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); @@ -560,6 +653,7 @@ static void csi2rx_remove(struct platform_device *pdev) v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); v4l2_async_unregister_subdev(&csi2rx->subdev); + v4l2_subdev_cleanup(&csi2rx->subdev); media_entity_cleanup(&csi2rx->subdev.entity); kfree(csi2rx); } From patchwork Mon Oct 9 13:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857246vqo; Mon, 9 Oct 2023 06:11:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlEPH8TMwgiI1fAMcoN0ice1zyr0wjH4AhM38F3BFLsmiAufpwuibf4ieqWKyWwLkXxaF3 X-Received: by 2002:a17:90b:1e0a:b0:26d:1f3d:6e85 with SMTP id pg10-20020a17090b1e0a00b0026d1f3d6e85mr12741377pjb.37.1696857078378; Mon, 09 Oct 2023 06:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857078; cv=none; d=google.com; s=arc-20160816; b=Dj8FzB1cCPVQnC+gGIzGxeVdFULhEtVHBCi2Sm1v0CobsTwc82grkLXdYRRdXdAfhP s1S8FQeFgmz0tg/oQO+jYQ0qnfO0dopJzWJurl3HvEi9ENWWAY9kvWzmMYNhWLDEo8qg d+1hCUrLYCgHApb0F86ITKFivqrWcgK+HLGBTrUAgeCEiJ183D9/4No2NJ5oeqhdidE4 b0+xKhYIAaH6KdIpkcY3r/S9t9Oxe1fBtwd78YgZ6+8OeraoI6xe9jzE+JiFePn36FLE ceti15cQ4t7rI58JUzg3XY2E4UZICm0kWXw0ROw00DzOyQp5WB5lpV8x68l70cqLq0UA 0pow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=osyCAViLVBaJwUwzPfMFvHCi5OOIvQquFZEhN1wmj6I=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=pzRUePLVoA798S0j9menAKne8TqsMi7pBtBS5jL6QcinAkAmU941X2JcRLj98ZBMtN MZuzgrlvWQERv9Zct3MfJeKgPlStMcmq2sPwRJGErWqj8FtOgOsR1Z4HQUF6WLsesJ8n jUYDXMWXrpB1Z6AS9+V9BWEjzrtLG3XJ4/lVTzbOLKBdzkbBNLBrUAssjIRSPycsGeRh BTVGixjd+EPIs4Mz9I64fneZmCCcziXU2hvdo4pvtA51pV6fbecUpTvpAgUHgzK8gILr Sf5bnWmtBW40mVQCFS389KSOfjGMUzbL0rqBZz5VjkN1jH2tXpCMm9fYc5UIuU6NVwx9 jkuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="rWIuf/JL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id m3-20020a17090a7f8300b002790b1320d4si11629914pjl.84.2023.10.09.06.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="rWIuf/JL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E345680AEE1C; Mon, 9 Oct 2023 06:11:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376872AbjJINK1 (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376810AbjJINKL (ORCPT ); Mon, 9 Oct 2023 09:10:11 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E40BAF; Mon, 9 Oct 2023 06:10:08 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9pIP067945; Mon, 9 Oct 2023 08:09:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856991; bh=osyCAViLVBaJwUwzPfMFvHCi5OOIvQquFZEhN1wmj6I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rWIuf/JL49ME416VKZNZTuJe/4Q05XdDE6WGE0KW/mvwmEst1cN/CcqoXNjADawD9 hdkNWLxlP+AqT1QT3fiXxgSl3u4xZa3T+ejgEnr1bi3LUV9+HpKiPLkfAEiWgDW7V7 k9tAEOXMKqZgoF++EtL+g6nPuYp3PR1iiIFlU2AM= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9pRe077021 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:51 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:50 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:50 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9nsj055571; Mon, 9 Oct 2023 08:09:50 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 06/13] media: cadence: csi2rx: Configure DPHY using link freq Date: Mon, 9 Oct 2023 18:39:32 +0530 Message-ID: <20231009-upstream_csi-v10-6-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1901; i=j-luthra@ti.com; h=from:subject:message-id; bh=RUZIs/V1zB7ojxrNBwsr2VePDUlHFcaYY3FI90aQFqc=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sqauE21D0LzrllxQ8Zm96qKPACTyyvIfOKE DfQrHtbhmSJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7KgAKCRBD3pH5JJpx RbiRD/sGU8AH/zCNvt5XjV9NEqO8d+OHg3Sue5Gk+a99KX6/iJNH6pKTXw2DwrGfI91tLvelI/P OTqtoxLacF408Tb77W/fide0gGKvZZMVjIR7ybBERGtit7W6pqXmGy6aovFDvC5N3dQI1XVy75W oF3r87dS6mv+7rVDmjmNy6tJ1bNobHB50wGDLCEImiJ7njN1SeDYBq96X52URntPTYDhQNHtOq0 qf9C1uZ+FAWL+XOM/RaM4BYAWkBO3Nz+n3TO59XsfX5wBg96GEHAUYa4bYGPtNw8OsM3jiUli4a Tydd5Wl2lk6QoZeMBTFSN473kkcKz7pJe4K7tAFcTTNbxJPlpb+fLRUy3duGbDqDvVdhu1AsQKm UrLcXIAMNEkx/04iHhp7i0x6QIqmwJx7qid0arCVM5uZW4fj+rGXhspyKqzYp6G1B4QxkUoOxw9 toj+ebKr+85lDxJg61/HEkGhJSsMLuiRdGzoIeVX5XEQBKFQrwIba5FHKqUecXArU7Q7afBAUDN bEMHfpAcGiuMg4bWzi8OaZoeVe3PEajHz8oDwfMhrpKQKi4NJxo97jF966uaAwYngkFGFR87NQn 5iAwRcDgEKTV43xizNfPlO2X/+yD1vCIjwVgx+LDQayvc9V1tKYQgCOSY5O2bfyqCB8cd4OOwYV +5G0xqErUCTcBpg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:03 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283608074262028 X-GMAIL-MSGID: 1779283608074262028 From: Pratyush Yadav Some platforms like TI's J721E can have the CSI2RX paired with an external DPHY. Use the generic PHY framework to configure the DPHY with the correct link frequency. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index f9b41451f4a4..77e2413c345a 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -145,8 +145,32 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx) static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) { union phy_configure_opts opts = { }; + struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; + struct v4l2_subdev_format sd_fmt = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = CSI2RX_PAD_SINK, + }; + const struct csi2rx_fmt *fmt; + s64 link_freq; int ret; + ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt, + &sd_fmt); + if (ret < 0) + return ret; + + fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code); + + link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler, + fmt->bpp, 2 * csi2rx->num_lanes); + if (link_freq < 0) + return link_freq; + + ret = phy_mipi_dphy_get_default_config_for_hsclk(link_freq, + csi2rx->num_lanes, cfg); + if (ret) + return ret; + ret = phy_power_on(csi2rx->dphy); if (ret) return ret; From patchwork Mon Oct 9 13:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857846vqo; Mon, 9 Oct 2023 06:12:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWL1Wv/3yLFLSTzLLWSWclcT0L2SWuA/6Ptsv7/XmfCQNxzH4fVATINGoYH8qROfpDDqPI X-Received: by 2002:a05:6a20:12d6:b0:15d:bc0f:9b64 with SMTP id v22-20020a056a2012d600b0015dbc0f9b64mr15947960pzg.45.1696857125928; Mon, 09 Oct 2023 06:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857125; cv=none; d=google.com; s=arc-20160816; b=OyIAuMdev5dsC7f/3mSdC3qcCZD4ido00MgorDPtSDcdwUOhepeI+T690kSqt0DF/M hCcLVD5sUyvM7VseCaqZVYFZDhqyUQ/SCQhA5Gj5JT+Gloqsa3Ptzf9HrPgdpZYmm1YW psA8pz6yCkhVSyTllf4HB8rItT7697v2L3zUNDGAg7l2R4e7yqxpzhgoro3fV0GkZEV9 S7kWe1rqJ+++g+rBMvp9iDR1yvFsr5Fy693sqFsXBoU0ZNPnEuoU/mdl/vsZK1YNs7t5 e17lXS8WWki6s9d6xo1kdq7vaJKwd7/Sse5DAlp4O1VpyKLaFiuP82PqmJ9UNXC50piz GILg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s/9/WCV+Z+pRzQZL2aiY/uIoSmDyX8F6tP63wjbi9vE=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=mX+3f3ODLmtEmRUd4FaVvNsJ3W44VhZ292jmj1EhQjdzhs06fhnLuxtx7KP8udf5Eh BikZEi1Vlyows/FbK8OwHmhWW/1LDQhMOYXGKXZP0n4bchJ6UnvPtX6rfp0jRALdckPE uORx0RrCV3fu+2Mz21lk/pGgoRL8AWvRsr4zrhYibo6XHRO9tNCBIvlP+sOMz+FAoV/c OSedenjojMX1xDo9oQ91CaBbCqn18yclDPYDrQZfYgqiaPX4rZol4v4IPFRy1LDxE9eS NWBkdv1JbrrwGUdt/K5lbTNuUpcY+ij0SrAeGqpbzeJ/+K5hhDO6QZfEAdYi2kzqPSjf MF0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=scGwhFKw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z126-20020a633384000000b00569cd6ead3asi9289411pgz.643.2023.10.09.06.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=scGwhFKw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AB7E48034A51; Mon, 9 Oct 2023 06:11:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376865AbjJINKY (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376799AbjJINKI (ORCPT ); Mon, 9 Oct 2023 09:10:08 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16FD9E; Mon, 9 Oct 2023 06:10:06 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9qX3067951; Mon, 9 Oct 2023 08:09:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856992; bh=s/9/WCV+Z+pRzQZL2aiY/uIoSmDyX8F6tP63wjbi9vE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=scGwhFKwA5pRAGoHG0YS/WQI2YiJzxEzzS8I1uiRTi+nk3z6AqGnz5kxIWcQ3GiT5 K3v5Iw7x7zvwgkqopdysJFBqpBk/5QOJXQ9hkF9a5+00/aIE8jRV+8O48E7AK80X8e 6ffWv408jey835cSZcI0UNf7cE2wyJ0LuEiF1Nk8= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9qDX021644 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:52 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:52 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:52 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9pe6118001; Mon, 9 Oct 2023 08:09:52 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 07/13] media: cadence: csi2rx: Soft reset the streams before starting capture Date: Mon, 9 Oct 2023 18:39:33 +0530 Message-ID: <20231009-upstream_csi-v10-7-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2047; i=j-luthra@ti.com; h=from:subject:message-id; bh=zwQO/Y0U7j6zw1eN4GZhJJir4qCqq/uRF3NrJzvTBjY=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/srZujrV2s5oLEjLN6orJklsHOAgav/7loNc tE/7oCCHfyJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7KwAKCRBD3pH5JJpx Rf2UD/9bxjA5/hCvux1X58DeE8Cjm+ol7yNkLScPpPXlouX36Ilq1806L6u4BJOnftH7aZkk109 luUFhs69wvW6doNpfpIjQ4U/2OgaJsqbF2R3vH0Q4wIUo8kwq/AhYQsANiLwM34X4czTIahidtb QlWYSBh1C97JXJSYfCLi9xhtNRZPGzfnMvuEYd6duj7N2ntnx7sOTjYOrm8N/kZGa2GQ2PFUZBj WkmYEPry3p9jQpw7IIC8Ys6BOpsUmrjw7wP8xclGE9sbE6gOscYS4hmugbBOidIUOViBLAJiM4r yEk7soEiFt9LTg/SNmgoW+PetF6vplyFr5bC5qxTZKljQCmVOumVyvaly0MLk3rMfoE2Q/jgoH3 oWTGYZx4b+OnYnz1R9HvbPD9hO59nlGIEkR77ZoZMHDv048jJ60apfKU8cmupLxP8o9E2hLrela 03Jlax2vwgtEdcBdXAEAtIcznwyT7TEOiPp9zZmsLePBf8uBBokH10i1W3HVCl/yIhFueGcXmWR oXzZV7YcNFbcg/VqQ5SF3eqfDaXNbDW0sRsqiRXuwFJiG3XjsengYrPHiHhpUnMnvyN1yyKocFw YjCiNc4O5T+V1RQas7jJYAA/TSSZ3PVCWZAHVFiHQFQFy+Kbp4uHnBBQTGbPqnRJ8/6IrowoX8E sNL9O4Hw4ctG5SA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:54 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283657812742270 X-GMAIL-MSGID: 1779283657812742270 From: Pratyush Yadav This resets the stream state machines and FIFOs, giving them a clean slate. On J721E if the streams are not reset before starting the capture, the captured frame gets wrapped around vertically on every run after the first. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Maxime Ripard Reviewed-by: Tomi Valkeinen Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 77e2413c345a..913f84c341f4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -40,6 +40,7 @@ #define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100) #define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000) +#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4) #define CSI2RX_STREAM_CTRL_START BIT(0) #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) @@ -134,12 +135,23 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev) static void csi2rx_reset(struct csi2rx_priv *csi2rx) { + unsigned int i; + + /* Reset module */ writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT, csi2rx->base + CSI2RX_SOFT_RESET_REG); + /* Reset individual streams. */ + for (i = 0; i < csi2rx->max_streams; i++) { + writel(CSI2RX_STREAM_CTRL_SOFT_RST, + csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + } - udelay(10); + usleep_range(10, 20); + /* Clear resets */ writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG); + for (i = 0; i < csi2rx->max_streams; i++) + writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); } static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) From patchwork Mon Oct 9 13:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857829vqo; Mon, 9 Oct 2023 06:12:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgAtbqc8NwBJx8dwP+sUkeCBTKaY/p6kqyUjaEZvpncVQ42OgVsMGOm0igRkGI0eZldGTl X-Received: by 2002:a05:6a20:9487:b0:16b:7578:1e4f with SMTP id hs7-20020a056a20948700b0016b75781e4fmr7355368pzb.57.1696857124677; Mon, 09 Oct 2023 06:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857124; cv=none; d=google.com; s=arc-20160816; b=SQ8WTZ49ZQcQcjmwOjekFo8uwQ/D/BECAVJAouXBEiO+gv7kpCULxGrSXKPBWTiiEz 5S+t5ZXLX964mBDclbBH4plNjhMqCLCyO7mxhj25Yb5XY5G71kJRSOPvmFqSAP51cDQf xW0LPxwOBj/GOPMwYhjXD9d9fWeKPpygSaGGiEQpVbtHc9LHMFHyj9XW2kFBfceaMXWI bG/J8YAaPn6ZaKTYTPGCBzehurnnPfn3nSoWafh+jPlPMNq1kjNL1OS6Jv6op87s6bTN oXdhaK1w66JhTFomETT/sdacUorATwPMN/ib+3aSggJQ24FJEd5slYP4bOQ6Bqdp3KPn htrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vtgYRdhRlk1YmzBEx3yb0mO0lU3pX1Lt5Kg7jv1XUqo=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=0emuz1BrkAFLicCzTq+1iDGoUDN1DhEy5BuUmZsRgPw00rQu1anBlw1gOOOCpsCXX5 mIQeRMKyCkE+7K/UvPjSjgrWjeJ2UJ9Y2XBsVeWEW2sh65fWd3vPXypoi3782XZo5w+0 nx/vCdwjfDUqtFZT622ZEaUApYEWVEnWuVX5YqsizfydznQ5/gsUn+F8urYl7J2Usuas JR7C9B9z0XHwWO2fxElBMkCT24BmynnH6jAL3qefS4YpkCO0YbeXXiAzqWNlfofnJTZC Mzk70OtKTj35jeQjZ+nwA1qi8U4sBkM8Uk8XTYbBTBuWGt3l9mWiu8rhQuJnnGADM8d/ NUTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KhE8Nnpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b0068e3f3c6250si7800555pfl.343.2023.10.09.06.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KhE8Nnpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BD07F808D296; Mon, 9 Oct 2023 06:11:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376909AbjJINKh (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376806AbjJINKK (ORCPT ); Mon, 9 Oct 2023 09:10:10 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCCA94; Mon, 9 Oct 2023 06:10:06 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9s5x035863; Mon, 9 Oct 2023 08:09:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856994; bh=vtgYRdhRlk1YmzBEx3yb0mO0lU3pX1Lt5Kg7jv1XUqo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=KhE8NnpkwZjv3z4LQITwymDZDqQlfBKXZE75SNdbh2c+BgGFYwFQLNXJTgXlbkL90 x4GDL4gtXxF1C62iVcQXu06A0Dw99Q95XY15ufuoZpfOpStJPSSwAZw0JCZ536D3Tv fzrD8cakucoQx+V/+kWyZ651xAeKER4TLPA0QXEM= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9sFW014548 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:54 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:53 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:53 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9rXu007359; Mon, 9 Oct 2023 08:09:53 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 08/13] media: cadence: csi2rx: Set the STOP bit when stopping a stream Date: Mon, 9 Oct 2023 18:39:34 +0530 Message-ID: <20231009-upstream_csi-v10-8-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2528; i=j-luthra@ti.com; h=from:subject:message-id; bh=yTXIIHZ7yHvfkBehaXvly8sQUzrqAsJQob6QxmW6ETc=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sssGXfTN0tDNfaKfrem+MZS1CyNLez01/xX 8FBJez74+GJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7LAAKCRBD3pH5JJpx RdRUD/98bxH17x9qQpAtrD9RgbsXY0FDbGxBI52epF0LkkxtecvitpLpr0KAgiW13usR0JGIHNu EICehuM9EwWJwElxkXdrfYR51fGXcJH3xU5oJM7cVg1GAiJrLmBzY4XxVmSE3r/rlxMmqpNlg/C tjPRGw1iGkTKZi8s/x6F5uoiu/37PkL/XoO2st9z0aLsOw4KZcNOsbBmypp5rx6AnWHmfstWcrb PmH2ja5f00Bjnl0FtoI6zwVDYbee/PWcM101KX4olF4xKspHU/hDHZ7rmQGi0UnUfq8tmZ3Qeur gpZvAZzYJBw13phWDqhZEm0OI89qW8L8pEL71xeYi8/trGPdN1TRLghqS2T2ol9l0HdDlZbCIK6 gJt4LwRBSGW8k1Xb9TdcuH+QQ7CKudBQcp7GYV9O0HxGvOfQvcu8JdmtMtd64bas4wWzU79DCVh BrvHeiXkt07ByBOYEVm2OSUOUkPyX5+bG/RhB2M6fjI2U4Ys7FjQObotwvLqSkwICygQCXyfI7Y ZbsV65Ye00kWINAg3IXGz07sNLErUPOvedAW4DlbugPK2bzrDzBxrxFsvC0RalwtYyr78noWizk W4uxQehxmSF3+qoQx5tD8ztWg4Jr3T8BFDHPihh9w0g3CUywcWpkFgwxZXZ0FcsNRIDdRDwDV+0 KH3YwIVWscwUnHQ== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:19 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283656058903668 X-GMAIL-MSGID: 1779283656058903668 From: Pratyush Yadav The stream stop procedure says that the STOP bit should be set when the stream is to be stopped, and then the ready bit in stream status register polled to make sure the STOP operation is finished. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 913f84c341f4..230c627ef1f4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -41,8 +42,12 @@ #define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000) #define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4) +#define CSI2RX_STREAM_CTRL_STOP BIT(1) #define CSI2RX_STREAM_CTRL_START BIT(0) +#define CSI2RX_STREAM_STATUS_REG(n) (CSI2RX_STREAM_BASE(n) + 0x004) +#define CSI2RX_STREAM_STATUS_RDY BIT(31) + #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) #define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31) #define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16) @@ -310,13 +315,25 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { unsigned int i; + u32 val; + int ret; clk_prepare_enable(csi2rx->p_clk); reset_control_assert(csi2rx->sys_rst); clk_disable_unprepare(csi2rx->sys_clk); for (i = 0; i < csi2rx->max_streams; i++) { - writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + writel(CSI2RX_STREAM_CTRL_STOP, + csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); + + ret = readl_relaxed_poll_timeout(csi2rx->base + + CSI2RX_STREAM_STATUS_REG(i), + val, + !(val & CSI2RX_STREAM_STATUS_RDY), + 10, 10000); + if (ret) + dev_warn(csi2rx->dev, + "Failed to stop streaming on pad%u\n", i); reset_control_assert(csi2rx->pixel_rst[i]); clk_disable_unprepare(csi2rx->pixel_clk[i]); From patchwork Mon Oct 9 13:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857131vqo; Mon, 9 Oct 2023 06:11:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpKjTZaoJZjG8114QPAskTh14WhmBZsT0WkpOBdbBlXAT3ZPFQ2On6eP99nagl9yVrLYl4 X-Received: by 2002:a17:902:d3d5:b0:1c6:124b:6158 with SMTP id w21-20020a170902d3d500b001c6124b6158mr12312267plb.30.1696857069584; Mon, 09 Oct 2023 06:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857069; cv=none; d=google.com; s=arc-20160816; b=WHY0Kwok9hrAlo1/MLI8Ssdwk031xCKOVOelgimX2vpdBeT8ukNqkCNfUYkx/0ZKYo mkKxEuMJWiiyI511v1vOEBnUTc/cqujMk+crSlfMifMVDBXVBW25vEK7gYGJuh2ko1uD qVcz0Q/7C/Ph9QYdEhpEpvd11k7UdwElXXkMglP+AXnwzSgCIUHhRpCJ5UQR4zq+PsIv 0S8Z/HhpYWiKxfsZkjp2A5JMu1ba3QVbUwCFpIe9BQhaxE7XJ6r4mTXTB+EAtiXmYxwV C+fb6K/j3aMP7qypzdH6uRcR8/C0CzYsNmbD5mTE35G08Sfcwe3F7zTTn8dVoWKeKb8S 3D/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5xRmA39JDsFhGm4qLUOCFV3dYHAJ5qXMdjUD4ivBnbU=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=h1JuzKpYpeSU6OIFV6tQ5tNH4cwp/UXmc3St6zvfUVa7UIdZet8eNBd/2mZIppl47s DmQz5NRP/dw66rH+wZjqxmuchEM6QeSrse4FDcweY9P0T0Eu36kAnq3JTumXXPW6/OOZ cIwie5ikApb0ASUa2PtgoefTjCxRSQaRK8hD8h4BHhN71cnDFHnmAfVbNKVJBNAmWyS8 Q5UixEAWNCWD5/9ccM2WLSEkE/yfG1bMmvkAd++VdI7+Lox1dHgR40PVpFYl57CVUhYO z37N84JEq9Ov67qG9nr41pRASnG1734ZxQdwbpZ8Or6rCrEzLzbf3DY68rjE12VtEAzL l91Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HO0w0sLR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id jx11-20020a170903138b00b001b973681493si8803713plb.16.2023.10.09.06.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HO0w0sLR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0F05F8081BC2; Mon, 9 Oct 2023 06:11:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376869AbjJINKm (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376797AbjJINKM (ORCPT ); Mon, 9 Oct 2023 09:10:12 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90435C5; Mon, 9 Oct 2023 06:10:09 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9tSP067961; Mon, 9 Oct 2023 08:09:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856995; bh=5xRmA39JDsFhGm4qLUOCFV3dYHAJ5qXMdjUD4ivBnbU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HO0w0sLRSKLt4pAD6hO1XFIBXflLGy4GDR9amEkyf/4SlsLQNLJkWeRj/Nh1MfPxz 5GIRNMdQkbajlm3qtz+J5OqhX+gX3Wse2mg2nWsVYNZ8GfqPFoHWsb6cLe6l6fqFYK XY6tXr5UXk1qibKGOP1oL/8Ya1UPaxMk9c1966OM= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9teU077039 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:55 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:55 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:55 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9s0l118038; Mon, 9 Oct 2023 08:09:55 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 09/13] media: cadence: csi2rx: Fix stream data configuration Date: Mon, 9 Oct 2023 18:39:35 +0530 Message-ID: <20231009-upstream_csi-v10-9-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2178; i=j-luthra@ti.com; h=from:subject:message-id; bh=rWhMSf+q3LWOfilXHfNOyLHKZTsa4nFF2tGubRsc2Js=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/ssHTbgeHRwXjG64y9LWLkV2aafsEpi2t0j1 75jF26bX9WJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7LAAKCRBD3pH5JJpx RfeXEAC39aSNwDNaFw8qNp8F4b6Gcr6ESVZsKxqhdS0So68tv74391OHuVCKzjNf2Su+R/Ju3u0 gpbwD+MHj7hHX6m60bKveGGD+iLN7e+XPWLWSoUIraT/k2sTlxZj4os9cNx2jFClcBccYXhGR+h PoGfM9gq55kmpXuE9TuRE2DsqKlaFQJUENqqTC1ywwyfttqqIOB8BhUWyRZ+2gJ5cqsMdy9x0U2 GDGaFYI1243fopq0nZolOK3t1LJl5MNGzauvv6LqMm3/evH6Z99HJkbbrPDG7LLTLNTwI4TcPVg 0EdTSHdXljTOKZD/tpqEINqMIOeHyVDM/TcFsKNplaMkIBEX/OQrD6cdwIv5B7I74mS2Itav/T6 3ztAuNipZQs9SWKq+VgtXCghCC2dExzv0SDAcNj0FN9UKsRrfdUzj+k46NtdlWrHm2l14R2d18k CU3Y+oy5FXbpHhSNa2M96XBN6q0fNpb7QxhiOL0up0ekbP4Sn6v86jxyTOy6W+C9lK2cgLe9+WN ovI654z+agGtfPSvB98oyOf/Nn7aFxcE3GzuI1DntOu6iF+HPLWZkxKrQf7xYc1jECXmkyGZa7Y svyW1P6it9VPe3jz9bQHzoapGgBloRNqsP/YGVON5hfkUAUsfUpq6TdvEZtOjFugIU+KXCvsTPa EB85EduQXPRBiFw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:05 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283598237313634 X-GMAIL-MSGID: 1779283598237313634 From: Pratyush Yadav Firstly, there is no VC_EN bit present in the STREAM_DATA_CFG register. Bit 31 is part of the VL_SELECT field. Remove it completely. Secondly, it makes little sense to enable ith virtual channel for ith stream. Sure, there might be a use-case that demands it. But there might also be a use case that demands all streams to use the 0th virtual channel. Prefer this case over the former because it is less arbitrary and also makes it very clear what the limitations of the current driver is instead of giving a false impression that multiple virtual channels are supported. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 230c627ef1f4..812f31dfaab1 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -49,7 +49,6 @@ #define CSI2RX_STREAM_STATUS_RDY BIT(31) #define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008) -#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31) #define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16) #define CSI2RX_STREAM_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x00c) @@ -271,8 +270,11 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF, csi2rx->base + CSI2RX_STREAM_CFG_REG(i)); - writel(CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT | - CSI2RX_STREAM_DATA_CFG_VC_SELECT(i), + /* + * Enable one virtual channel. When multiple virtual channels + * are supported this will have to be changed. + */ + writel(CSI2RX_STREAM_DATA_CFG_VC_SELECT(0), csi2rx->base + CSI2RX_STREAM_DATA_CFG_REG(i)); writel(CSI2RX_STREAM_CTRL_START, From patchwork Mon Oct 9 13:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857542vqo; Mon, 9 Oct 2023 06:11:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQFEYpVFK1iKMdp7FhDc7IPhES5xRb7o4iFYoAifcorxf8uMFfvJiRsZNoV98hS3M6FIlL X-Received: by 2002:a05:6a21:7892:b0:12c:2dc7:74bc with SMTP id bf18-20020a056a21789200b0012c2dc774bcmr18661222pzc.46.1696857103328; Mon, 09 Oct 2023 06:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857103; cv=none; d=google.com; s=arc-20160816; b=R8BcF3LbEAmMgVNP8cGBq5BCYmWbIy+Gy2PMe+4dZ9l0EySayaN1a3893sXmjrBgnr LMPPV0s2r1trN4FG5GoBGRDa8J2ifkMxZaWSOuR1psfhK1vnpLiXUJWT/bpVwlUwobpI f/XtNYjF2b04JSWmk1KgbvXBoY8tWbbZ7LfkdWPobmaqXzXLirjRfCsHxLzBkYIpSogs b5+Q+EJUQ26+7fyO3+2PRHVQ+/rU0KxCJ8O5m5joJRZmYVneULLslSVu3owMP0qQkM3A tShpxL400CoN7+c03xGzIXNSOpecjK1sHvgLTW8gqW7hidMf5OhBrPiQF3WEOn4l2eFs +mxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wzciJJ2YTFJVP2b52Ols5dE9idQaEIAPyxn7t7coENY=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=KaE8H6OunH+dcQ3n7yeHx6uwxneC6ga6L0+QhQRhDyBi1OLg+hPFjiav+RhmfHG4O7 xnTgUde2EHcg10euZfOOMlTUDsSgOTGe0imCeNSpaBfsMyKA8HsOt06pCG4NL+lgFgiP zYGlKVrM/5mIGOIafVMiTUzBuwR5R/w7BAv3/jn2mImDg8MgjOczm033C8rvQE9Colbk S2EbUVJKoICyInWeoFeHw+IYb3womg2rscWNybh6Vm+/H/q4NOTAP1OUNaB0zpMcPeo9 Uu9Vr6HnwsGx0kLUYmGTZkBT6fRp1bEbr1uw2GWJdcbGaoso519Mtb7NqUNhYqG47tDA +lyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CWfc5bqv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b9-20020a63d809000000b0057c9e0c7bb7si186984pgh.77.2023.10.09.06.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CWfc5bqv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5B6B0809D3D0; Mon, 9 Oct 2023 06:11:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376896AbjJINK4 (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376779AbjJINKN (ORCPT ); Mon, 9 Oct 2023 09:10:13 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6159E; Mon, 9 Oct 2023 06:10:11 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9vDe055536; Mon, 9 Oct 2023 08:09:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856997; bh=wzciJJ2YTFJVP2b52Ols5dE9idQaEIAPyxn7t7coENY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CWfc5bqvAQaJLN6j/XkXFrcmRO0vP4UOBG90Wuk/yJGdrSYaYvBOOi1EAw0NVax0+ rTI6Y4wz9EjS+CG1H3MYsND92S/ZyE9UfpJ+37vJ+g3xUiPPA/ocBLSxdRiI/moDuI m5RAW9qI3zIt0EGQivA2/hf1/czJQjlwqs3/cWG4= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9vr6014598 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:57 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:56 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:56 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9uYE007422; Mon, 9 Oct 2023 08:09:56 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 10/13] media: cadence: csi2rx: Populate subdev devnode Date: Mon, 9 Oct 2023 18:39:36 +0530 Message-ID: <20231009-upstream_csi-v10-10-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1279; i=j-luthra@ti.com; h=from:subject:message-id; bh=bDHn/MyiN9Cg1dBR/V+/tvt/oG+ArF4duwVMUN+kd6w=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/st6XqfcSRECGzh8gspwZdhiJGOXJDFbNkmQ 2yEKKpbYtaJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7LQAKCRBD3pH5JJpx RVmAEACdtqsZMsiylF4NAfMIE2WT+Pq8Db2VpoPxWm0zq6gcuy7eOdX6rrry8TPhQLP6zr0Vy1u sXJpAizqJLsGDw9pLNdrGM6DD4bBkUIHC9LFRF18JL+Bhbg7tS3WCpr6bfOZIJP0UTVRVUgxxnQ 8hNTso1LvKTsXrBzT8GReQN/s6V0L1XMpTW21ATreVisbWn8Hx6eHPslspd0IDWq5UO9cbNruhK TC8rbMJr1Rkmgrdqy32B+ozS2FZiO6OQzB+EB+t9+eyQ4DcN7H2FIgJF5dkU5iy/rf9nopfXhMx chZlz05N6KOIoBBIhODTWZ/5FAZv85Bi6OznIUZPHvjHW8j57eGaAuW9EOxjzASw/NWTCGY82Fe wZ1R7Juy9eGHORHhGhwBwV+WCZ2p6Q8wbyG3JlLt+zDZqzS9b3NM1EcXd0qd/EaZef0sfOTvUpl C/Qi3nFFYqpoj1JxrjDW1MOMNa2cdthljgz6vQexM7TpvZ+PUIcIojcJQ5rnb/wH14DAOOun1mB bG8nd2CftzfGXL7oBeLNMHfREOFx6EYP4e14NRhc3y4zG4Urxf02z9048rDCF38l2WrRO14GPNo VIZ1KRpwspstUA94VIoZdAt2wISbIhTlfjyKHowDwKA7B3m7p3NQAaVIZedV+ThqXNggqOrHx13 tG7JlSe0uP0Nfaw== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283633553340384 X-GMAIL-MSGID: 1779283633553340384 From: Pratyush Yadav The devnode can be used by media-ctl and other userspace tools to perform configurations on the subdev. Without it, media-ctl returns ENOENT when setting format on the sensor subdev. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 812f31dfaab1..d0c2a5b3d0d5 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -668,6 +668,7 @@ static int csi2rx_probe(struct platform_device *pdev) csi2rx->pads[CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK; for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) csi2rx->pads[i].flags = MEDIA_PAD_FL_SOURCE; + csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, csi2rx->pads); From patchwork Mon Oct 9 13:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1858409vqo; Mon, 9 Oct 2023 06:12:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8W7fKMGS1dJ01SVmduNbiweW+B3h8l+F/mD31qlW2rlcXvP8k6ADP5JpDc+MeFXhTZKW2 X-Received: by 2002:a17:90b:207:b0:263:ebab:a152 with SMTP id fy7-20020a17090b020700b00263ebaba152mr12311131pjb.19.1696857176395; Mon, 09 Oct 2023 06:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857176; cv=none; d=google.com; s=arc-20160816; b=OUzKGvzOhWLbvutghC3OhcV3GCYD/k8yQByd47kkosXNo8lQ637YAwHUN7MVFJv8/n bKBx/Gat+5OUH+DjyG6dHIjRdm7P3rjETSJJqSqZ64UJ+Dmr7fkHZsw2Bx2VlWO1pObY TXf8/gkXrfRYBa5kg2Xr/6B3R6NhLyNY65XR0RLm7jqqZVAHzk5kf5J6s1duH5ZqXhmu 6JHRuiZywh9wYBt8dIbk0HUosKwU5Aa9mnDd9Ce95eguyh6ThvmlLsVn/qanJJiY5qqx CS/F7bkOJLOS9qHW5YcOx3VGzIN1i3LEglNy3a8u36QocqoR349CDMTlUZ13dzTug/Tf Syxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=07dWCB21kyjDiChID1v5HFl8K/TwWhxZIuKPCitG0vg=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=rNhdL7+2irMm3r6D0JFOfK3FI8HVIy92tjgSyxOtMxJOZjVG/BWEffGNM8VQSpYrKG /T0yL3pfP1vcW8JTnLLTFLq+g9EcJD2h0Vl19r+HnRzXpkoLmtTFyma9iB2cIvUda+PQ Hkyq3EKs1zxHoGtf0KQf8c0zZ12Vnl43+jj9FWm6PhNFey6jBaeH1zFYwSGAwl8VPOzE zoCcO79qWD4nbRnV4fU7IT8MQDQHhCYXr6JxwkozEcVvUvyFl87cjS0RUEhtAWV1SWo/ SyMrKsiCYBafOyzYuiXaL4LdYt6hAI3kXCAmt9r2TALSCygfuo/MOjLdU61D4qLMIlzs b9/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BGuXCaK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id na4-20020a17090b4c0400b00263c23a5693si10293062pjb.13.2023.10.09.06.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BGuXCaK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 340748036866; Mon, 9 Oct 2023 06:12:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376919AbjJINKr (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376788AbjJINKM (ORCPT ); Mon, 9 Oct 2023 09:10:12 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E137DC6; Mon, 9 Oct 2023 06:10:09 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399D9wB3067976; Mon, 9 Oct 2023 08:09:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696856998; bh=07dWCB21kyjDiChID1v5HFl8K/TwWhxZIuKPCitG0vg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BGuXCaK51VjDHP+GrftwE208jXP/YXXokTN3CL5Nv0OA+ByloTrnkragHLsYzJKDp oQWn1+VwYApYxSt69aqEmKu6Eq4JhImCu7l4AoD41z+wH/Orn3prUtFEMJbiNwfNm+ IPzh4pQ0t4qxLGzIepgLroSmmGoAaCD/x+LX3/xg= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399D9weH071560 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:09:58 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:58 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:58 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9vHh055692; Mon, 9 Oct 2023 08:09:58 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 11/13] media: cadence: csi2rx: Add link validation Date: Mon, 9 Oct 2023 18:39:37 +0530 Message-ID: <20231009-upstream_csi-v10-11-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1569; i=j-luthra@ti.com; h=from:subject:message-id; bh=zo2hhYXbGio5ee2AnO4qGHe/0axDO9Ru33qV+Q96O/g=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sujDKPDTZgS8DjBKPkV3nZaRwdBaRViIeP5 xP8SJiUx7OJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7LgAKCRBD3pH5JJpx RXWAEAC0/lEKXqIXdPmkqGm2QKz7hgG6egceWWJTskc/AhBUncWgdWa1OPpu/WUq1gj2ZIahjqq 9Igkyu7Skk5cwW5nCdRn4PuADw4AX0Yt4gJ6WiOPh2knVYbavEjRalWfIkfb+I1DoQd4JvIxYUE Wwr4Y6eOi8dtYR4cOJuWRZ0uhq+XpO4i7ipEjYhUcfKFkY8K3RhvmBvkp+15AiMOlezbAgZeNcw fhR1859Gtv0ppmK7qISpVVDj4pjjgkMYr708y67uyz0RRpTLCQ60Fcge5pXpGCmaHIMUx9MZAih Nh5qAoQtv3kHmXsUswMvhtaGK/C7IzD1kza8b0ZguOWqtPnRKWgA5oYLXOQjEwGV8yd4PIzwVuy IaamnFjJVsushLfEFrPDuPcRpYS0Ai73SE0n2Iul0wnz6y2X19+j8QvXpPX3mODBUAILXtBXQRD opRpKrsRl56Rdv1nDdI1/xXfY82/DGefzjVdR6l9wEp/v/0KSc8U2y5SEabe8FatILDnPDGdQcR 1bj47PpVA67K8S7FW0wY8WiKZ9jKJ0yXPdY8Gpp64Z6/0aLIn55pkxEvfOVX0IvTGN3wvLsTkET wTUCNQ8PQ8/rZOBbC6CKZCVUq7MUMIy9BP9Zsl5QS4dpcJmrImUhrwhwVNNC3eJOgQtMZ97lq56 KRtvmIFgHqiVIJg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:12:38 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283710686821625 X-GMAIL-MSGID: 1779283710686821625 From: Pratyush Yadav Add media link validation to make sure incorrectly configured pipelines are caught. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Maxime Ripard Signed-off-by: Jai Luthra --- drivers/media/platform/cadence/cdns-csi2rx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index d0c2a5b3d0d5..889f4fbbafb3 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -453,6 +453,10 @@ static const struct v4l2_subdev_ops csi2rx_subdev_ops = { .pad = &csi2rx_pad_ops, }; +static const struct media_entity_operations csi2rx_media_ops = { + .link_validate = v4l2_subdev_link_validate, +}; + static int csi2rx_async_bound(struct v4l2_async_notifier *notifier, struct v4l2_subdev *s_subdev, struct v4l2_async_connection *asd) @@ -669,6 +673,7 @@ static int csi2rx_probe(struct platform_device *pdev) for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) csi2rx->pads[i].flags = MEDIA_PAD_FL_SOURCE; csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + csi2rx->subdev.entity.ops = &csi2rx_media_ops; ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, csi2rx->pads); From patchwork Mon Oct 9 13:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857444vqo; Mon, 9 Oct 2023 06:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFcMsHy7aiijQqF+4kDtFhrjPl/BeHXHHvqqZfbNTIUyGtQ1sdafoA6TUJsgBfm2wt3O5p X-Received: by 2002:a17:90b:17d0:b0:276:4d97:7cbb with SMTP id me16-20020a17090b17d000b002764d977cbbmr12995051pjb.17.1696857095318; Mon, 09 Oct 2023 06:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857095; cv=none; d=google.com; s=arc-20160816; b=FunFGn9y+iM0zaBDUJ/T7+2nKqjdKK9MEgZ1+rmdGoSqB6uPw+RcXQ6FKwAE6E9nw8 rd0U69X7MDV2cJ70KCPVSLtH29WQwGPIvFjugtY1pxecBQBOP6u3CdmWs20y6NIPoj1e 1xjlta7UFcC867ZFmabKpy6tZH8PM8BsmfuGmJ2dbtpHT+x/DcONXKXOkCnaKLblg7En jLFRiOW4z2XVW6iTYaECSyPeXUJ9bm+54mrFC8CozSe1xHudsX8v3QhTGlzuFcn47VVk 00pfupqtrMJTbqaelOwyPOJpQ+jLLnmlLzCGARc2IhBSHW6iIRK2Osp3yB39Z7fVcr7v K+hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3Vqk9vVCGrxtOKvkqDWGzK4D6doZ6z6B33JrgumrcKU=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=r4eq/cMSWLywuR5WXh0DLRtCncxKSNm7hIrvM7Bf5Uz5J22XmOtPSySFiru8eT+nFj ctYEuuVUAxe6jmwssoN2fyTGic7lPW/ZdkMUFAyxGh6tyx2k2XQNC8YYM7/ViyhO+r6t 9BH3/pq51seBlZUtoR56PFDNxJmnVzvaO9CN2CDUtzFEM5rZowcPJZ+YH6i0bP0f3Cav Th0x2XGmpC6Wb1WAir5H8JQKDs1TFSQT4Pcdf2K/acrM++/ja8McqFUGVZq/qX5NCt56 pNYSomQ4MLBqfWk9BcFz2hy1yFlvT6XYDgx119O1WKQsvmqOH2Pb3r/+pCZKfGZQ+A+C 4nQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RLrIQnZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id pf12-20020a17090b1d8c00b00278f81e54cdsi12972776pjb.19.2023.10.09.06.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RLrIQnZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 606658021584; Mon, 9 Oct 2023 06:11:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376884AbjJINKv (ORCPT + 18 others); Mon, 9 Oct 2023 09:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376826AbjJINKO (ORCPT ); Mon, 9 Oct 2023 09:10:14 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43536DE; Mon, 9 Oct 2023 06:10:12 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399DA0Om055542; Mon, 9 Oct 2023 08:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696857000; bh=3Vqk9vVCGrxtOKvkqDWGzK4D6doZ6z6B33JrgumrcKU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RLrIQnZGVAK0q1HrHCTv5jvyi5Y4vy+pLrEws1ATl2PuJfvbdHWqSzlrAH0ienm0X mP+rO4lfFwgO9tE74IIFK3sJLYuamVeXmkNn7MBMAEZqd+OHNfQfquOW+pxSASmPSo QmkNEWCTW67KZF1AnAIngQ8+oKMwiR/PH8uNBve0= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399DA0Ic021686 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:10:00 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:09:59 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:09:59 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399D9xLj097070; Mon, 9 Oct 2023 08:09:59 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 12/13] media: dt-bindings: Add TI J721E CSI2RX Date: Mon, 9 Oct 2023 18:39:38 +0530 Message-ID: <20231009-upstream_csi-v10-12-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3456; i=j-luthra@ti.com; h=from:subject:message-id; bh=WYour5MHSnxPJZpjcSMo7Wyiio5vA12V0oZpUUm9GB8=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sve3Lp7c8vQpNZBJsppkyHCOLXPNxwgUlli Fz5VnW/hpeJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7LwAKCRBD3pH5JJpx RT2bD/sF4BQGBzybXda5AwzLpyvjQtrYkHp42blCCZ6ON1Jd9Bh71YRKdNLCruRZUghYCIsbEju 3/7di58TJdStCkZ5kKgT98RaavWbZ80IPytmJOOwMlewZwpF3C9TH7vsJLQ1tLKHk1oazOy7/fC 1B+lEIs+dv4FFVJRHLH3wpUJNE1RFyabfR8a6hvvTd9glysnvcGlgWAKAaSUuo2m0DKU4Qf2MKP q+c+8LDcHImsSZW/A0GoELKVwC79sAznI+q8h6woPcq2oSwPKytCrhGn9yxx/D3nwFeoCOlJvwW e3l07CUGo2Wg65Jd/u27BQfHvUGU5McZvVcBiIWLJkWZUHMUzG5Mxxi0X94n+mBRR83bb3/z7IV JomKA3yLkbDTW4712fKr2xsAIJ3klPEvCOCnwHQ+5CX9a3ze6PsXVNkxSNozs9j6LE/cFcfaGB1 uW0/STReFakqReCLhcRB1WRtZXhjAO9DwV/zJcXCrADSqHAROnV24wxeKcPcvLTbATS9u3aL2IX NhNGjWs8jt35Cw1y5ivgBvhFc/dfk4Xjtio2cIYOjdFXKzAmuPxMwkTvyverpDxXQWCsiIJGSnZ oHlyMu1HE44y+zZkOsd2Gb2/J29WAnPZuLxP3/rtAC4Ft2Q0TKlzoxs+dFoNGjhMtrsEU51mgiW GGNZZTRjfymkckg== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:29 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283625650195764 X-GMAIL-MSGID: 1779283625650195764 From: Pratyush Yadav TI's J721E uses the Cadence CSI2RX and DPHY peripherals to facilitate capture over a CSI-2 bus. The TI CSI2RX platform driver glues all the parts together. Signed-off-by: Pratyush Yadav Tested-by: Julien Massot Reviewed-by: Laurent Pinchart Reviewed-by: Rob Herring Signed-off-by: Jai Luthra --- .../bindings/media/ti,j721e-csi2rx-shim.yaml | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml new file mode 100644 index 000000000000..f762fdc05e4d --- /dev/null +++ b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml @@ -0,0 +1,100 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/ti,j721e-csi2rx-shim.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI J721E CSI2RX Shim + +description: | + The TI J721E CSI2RX Shim is a wrapper around Cadence CSI2RX bridge that + enables sending captured frames to memory over PSI-L DMA. In the J721E + Technical Reference Manual (SPRUIL1B) it is referred to as "SHIM" under the + CSI_RX_IF section. + +maintainers: + - Jai Luthra + +properties: + compatible: + const: ti,j721e-csi2rx-shim + + dmas: + maxItems: 1 + + dma-names: + items: + - const: rx0 + + reg: + maxItems: 1 + + power-domains: + maxItems: 1 + + ranges: true + + "#address-cells": true + + "#size-cells": true + +patternProperties: + "^csi-bridge@": + type: object + description: CSI2 bridge node. + $ref: cdns,csi2rx.yaml# + +required: + - compatible + - reg + - dmas + - dma-names + - power-domains + - ranges + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + + ti_csi2rx0: ticsi2rx@4500000 { + compatible = "ti,j721e-csi2rx-shim"; + dmas = <&main_udmap 0x4940>; + dma-names = "rx0"; + reg = <0x4500000 0x1000>; + power-domains = <&k3_pds 26 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + cdns_csi2rx: csi-bridge@4504000 { + compatible = "ti,j721e-csi2rx", "cdns,csi2rx"; + reg = <0x4504000 0x1000>; + clocks = <&k3_clks 26 2>, <&k3_clks 26 0>, <&k3_clks 26 2>, + <&k3_clks 26 2>, <&k3_clks 26 3>, <&k3_clks 26 3>; + clock-names = "sys_clk", "p_clk", "pixel_if0_clk", + "pixel_if1_clk", "pixel_if2_clk", "pixel_if3_clk"; + phys = <&dphy0>; + phy-names = "dphy"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + csi2_0: port@0 { + + reg = <0>; + + csi2rx0_in_sensor: endpoint { + remote-endpoint = <&csi2_cam0>; + bus-type = <4>; /* CSI2 DPHY. */ + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; + }; + }; From patchwork Mon Oct 9 13:09:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 150097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1857694vqo; Mon, 9 Oct 2023 06:11:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHle5vTv/M7LOHUwv1kv3JvPOl4Gk8CgxG2slY/TG4ZaPM1O9gJ968/UwMphgqI6aG99MR8 X-Received: by 2002:a54:478d:0:b0:3ae:5e7:6e89 with SMTP id o13-20020a54478d000000b003ae05e76e89mr15411309oic.2.1696857115596; Mon, 09 Oct 2023 06:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696857115; cv=none; d=google.com; s=arc-20160816; b=eYk4gBpHgCmQNoXLEWKwkgW8ES5rj4UaNjm2THJV/hSm6JFKobzDdVxZZ6lmXNZQNH ETaNsstAvMuT39VPkmU0hpzehl2deqarFrEV87HNF4IGkeTYwLl5Z8LmXPFvGbNJazio gmjGbivRfH+b9PSEf4asJspOdaCbHiYNDRLtENSnYYslfyq0Rn+wZ55xfpmieXU/CU6d U3v08uQokGZ3UYLUAHaC0026iNou72gjhVvYTx8T760TAzmDYwnmmGtEMq3M9WBRhZwH GyDxMfqsa9M5UweTYZj7S6FUMvWMITaOKL5q51+d5PRg8w3YjWTrYfI47WEpigfMxm5W GtIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gt+dnbi3J4RNeYKejbpT6PIw+CJYk4iSkxil/3NZzT0=; fh=6xb4dRkd2+1fqSC803o7QgwwC4DGCN1bJaIcF3oxTbc=; b=namIHwTuREaPTSlMh40/EgG1TA9QfC34mcg7VKDuNtuXD/hmb+WD1y6ugDfLLoLNs5 e9XMgm94t4js6vMZcUkrEUv8SXZDp48/WPbWsZPrDu4244RUj1nJ36QN2+kAGqjYf3A+ zuywuBEx2MGCl9gumT0FLKb4b/CulZHszeN3wHVayPOFzwVMRaGN+XPdZnIxqHxBh7nA dZUbtQI9YeCefHMO6nEcpkP3MrKTV95flY9SHsJRU6TQ4sWqKYZ42iTDwFTwWPF6MbMK sQYwb9faf/ED9IPUzPMMbSmhP23zUmNwlF2T25pVXQyAqniCZn9nIIpuAbFnNc7fwWG5 RJOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HkGnDkEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y64-20020a638a43000000b00578e4816c9asi9555948pgd.19.2023.10.09.06.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 06:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HkGnDkEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3A27B802B562; Mon, 9 Oct 2023 06:11:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376841AbjJINLH (ORCPT + 18 others); Mon, 9 Oct 2023 09:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376859AbjJINKm (ORCPT ); Mon, 9 Oct 2023 09:10:42 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84172109; Mon, 9 Oct 2023 06:10:20 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 399DA158043973; Mon, 9 Oct 2023 08:10:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1696857001; bh=gt+dnbi3J4RNeYKejbpT6PIw+CJYk4iSkxil/3NZzT0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HkGnDkExaAdIQTN8Qx/yj+4zbbrgqjY6JT5DXyVC/6djidLCT+G4Mn5i5hGrPqSaf CB+3c4bLEfzO4Ti2hUSyXGJuFMejsaxUICuxbSy42qqdrgHGJHfzhLX/mM+aJaCFXZ MTsQ/c0UMSQcsAtIhUP7eYyMUWZbTiVaDcNYH30Y= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 399DA11m071609 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Oct 2023 08:10:01 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 9 Oct 2023 08:10:01 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 9 Oct 2023 08:10:01 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 399DA0kR007610; Mon, 9 Oct 2023 08:10:01 -0500 From: Jai Luthra To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Tomi Valkeinen CC: , , , , Laurent Pinchart , Mauro Carvalho Chehab , Maxime Ripard , , Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , , , , , Martyn Welch , Julien Massot Subject: [PATCH v10 13/13] media: ti: Add CSI2RX support for J721E Date: Mon, 9 Oct 2023 18:39:39 +0530 Message-ID: <20231009-upstream_csi-v10-13-330aaed24c5d@ti.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> References: <20231009-upstream_csi-v10-0-330aaed24c5d@ti.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=37113; i=j-luthra@ti.com; h=from:subject:message-id; bh=NHNjD6zSAyRPK+ay1Q7xnxoMSIxJggpY4NiPdJbmT7k=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBlI/sw2mn3y3STRPxrX/Zt7Siqiw6OeHQPo/TeZ N4cwV/tSf6JAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZSP7MAAKCRBD3pH5JJpx RShmD/9lDr+93pg28Ls/gJy8FKQxvXc0ybN3ogKngmpvYyjmv49HjrBhufJORVsQtCS3sAcQTUC l8CvIJLFFIWByChIVPVNOqNdhECTLIYcfdvmJSJnFA6j+6A4Uoy/wK6DMK+WM3M2qCr2ZPgF41O v41mFp+rwUdXrp9/9iqcmWQgOKESHKLM4LpB5MHa+7/+AzHmpY+qajgIkwiwYFYOEz60M2l/oux t0nt3YecMAMx50q/Z72jAJBJzmIqH6GBjQzAMYo8rTUnwvB9BfywQkNgg71X4APmABsm3XyWwE4 EBmwLkaDjYYz9XUA/CzQZ14Cj/XCevBzODSaP0LJZqnjJyKEFVp3dBy8aCIEFdWGevTKMq5egry X4XzRPeNufb8opCi51UniwOz+7xXZw6iJPdg7c8/gd3as08RICiDA439r/iRXpem83QBgYYYU6B obcdM2KBIYHG8xRRJEALd/B/SRDxcIoAQ+OskZE1Wnp6zAL2URasSml9ymHKL4aDt+A8cUXjJVt yZOX7QJefvsOyd03PKu1w3B3Eo6by4k2+Dw0QE7Ej95WNxg15tZpwI1NOvdVhrwN6ZQ84k23Gg9 3qc4V3k/NU/gfJCfrwyKdNaP+t/MTuRPDpLt501d6o4mJ+ocbVbvFWY0XA79kVirpF/iX+j7Qas jjY8T2O760qJdmA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 06:11:36 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779283646387792927 X-GMAIL-MSGID: 1779283646387792927 TI's J721E uses the Cadence CSI2RX and DPHY peripherals to facilitate capture over a CSI-2 bus. The Cadence CSI2RX IP acts as a bridge between the TI specific parts and the CSI-2 protocol parts. TI then has a wrapper on top of this bridge called the SHIM layer. It takes in data from stream 0, repacks it, and sends it to memory over PSI-L DMA. This driver acts as the "front end" to V4L2 client applications. It implements the required ioctls and buffer operations, passes the necessary calls on to the bridge, programs the SHIM layer, and performs DMA via the dmaengine API to finally return the data to a buffer supplied by the application. Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Co-developed-by: Vaishnav Achath Signed-off-by: Vaishnav Achath Tested-by: Vaishnav Achath Tested-by: Julien Massot Reviewed-by: Tomi Valkeinen Signed-off-by: Jai Luthra --- Changes in v10: - Fix bug around YUV422 pixel ordering in setup_shim(). Now we passthrough the incoming order of pixels over MIPI (U->Y->V->Y etc.) when storing in memory - Only allocate 32KiB of memory for the drain buffer, which is the upper bound of the PSI-L endpoint's internal FIFO storage (2048 x 128-bits) - Allocate drain buffer in probe() instead of start_streaming() - Set other colorspace/encoding properties in the initial device format - Make the module compilable with COMPILE_TEST if Cadence dependencies are missing - Address Laurent's review comments around naming and other minor comments - Address Tomi's comments around better explaining the scenarios where DMA drain is required - Change module/patch authorship to myself MAINTAINERS | 7 + drivers/media/platform/ti/Kconfig | 12 + drivers/media/platform/ti/Makefile | 1 + drivers/media/platform/ti/j721e-csi2rx/Makefile | 2 + .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 1159 ++++++++++++++++++++ 5 files changed, 1181 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c934244acc31..01ec2e6e122f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21714,6 +21714,13 @@ F: Documentation/devicetree/bindings/media/i2c/ti,ds90* F: drivers/media/i2c/ds90* F: include/media/i2c/ds90* +TI J721E CSI2RX DRIVER +M: Jai Luthra +L: linux-media@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/media/ti,j721e-csi2rx.yaml +F: drivers/media/platform/ti/j721e-csi2rx/ + TI KEYSTONE MULTICORE NAVIGATOR DRIVERS M: Nishanth Menon M: Santosh Shilimkar diff --git a/drivers/media/platform/ti/Kconfig b/drivers/media/platform/ti/Kconfig index e1ab56c3be1f..bab998c4179a 100644 --- a/drivers/media/platform/ti/Kconfig +++ b/drivers/media/platform/ti/Kconfig @@ -63,6 +63,18 @@ config VIDEO_TI_VPE_DEBUG help Enable debug messages on VPE driver. +config VIDEO_TI_J721E_CSI2RX + tristate "TI J721E CSI2RX wrapper layer driver" + depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_SUPPORT && MEDIA_CONTROLLER + depends on (PHY_CADENCE_DPHY_RX && VIDEO_CADENCE_CSI2RX) || COMPILE_TEST + depends on ARCH_K3 || COMPILE_TEST + select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE + help + Support for TI CSI2RX wrapper layer. This just enables the wrapper driver. + The Cadence CSI2RX bridge driver needs to be enabled separately. + source "drivers/media/platform/ti/am437x/Kconfig" source "drivers/media/platform/ti/davinci/Kconfig" source "drivers/media/platform/ti/omap/Kconfig" diff --git a/drivers/media/platform/ti/Makefile b/drivers/media/platform/ti/Makefile index 98c5fe5c40d6..8a2f74c9380e 100644 --- a/drivers/media/platform/ti/Makefile +++ b/drivers/media/platform/ti/Makefile @@ -3,5 +3,6 @@ obj-y += am437x/ obj-y += cal/ obj-y += vpe/ obj-y += davinci/ +obj-y += j721e-csi2rx/ obj-y += omap/ obj-y += omap3isp/ diff --git a/drivers/media/platform/ti/j721e-csi2rx/Makefile b/drivers/media/platform/ti/j721e-csi2rx/Makefile new file mode 100644 index 000000000000..377afc1d6280 --- /dev/null +++ b/drivers/media/platform/ti/j721e-csi2rx/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_VIDEO_TI_J721E_CSI2RX) += j721e-csi2rx.o diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c new file mode 100644 index 000000000000..ada61391c8d2 --- /dev/null +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -0,0 +1,1159 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * TI CSI2RX Shim Wrapper Driver + * + * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/ + * + * Author: Pratyush Yadav + * Author: Jai Luthra + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define TI_CSI2RX_MODULE_NAME "j721e-csi2rx" + +#define SHIM_CNTL 0x10 +#define SHIM_CNTL_PIX_RST BIT(0) + +#define SHIM_DMACNTX 0x20 +#define SHIM_DMACNTX_EN BIT(31) +#define SHIM_DMACNTX_YUV422 GENMASK(27, 26) +#define SHIM_DMACNTX_SIZE GENMASK(21, 20) +#define SHIM_DMACNTX_FMT GENMASK(5, 0) +#define SHIM_DMACNTX_YUV422_MODE_11 3 +#define SHIM_DMACNTX_SIZE_8 0 +#define SHIM_DMACNTX_SIZE_16 1 +#define SHIM_DMACNTX_SIZE_32 2 + +#define SHIM_PSI_CFG0 0x24 +#define SHIM_PSI_CFG0_SRC_TAG GENMASK(15, 0) +#define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) + +#define PSIL_WORD_SIZE_BYTES 16 +/* + * There are no hard limits on the width or height. The DMA engine can handle + * all sizes. The max width and height are arbitrary numbers for this driver. + * Use 16K * 16K as the arbitrary limit. It is large enough that it is unlikely + * the limit will be hit in practice. + */ +#define MAX_WIDTH_BYTES SZ_16K +#define MAX_HEIGHT_LINES SZ_16K + +#define DRAIN_TIMEOUT_MS 50 +#define DRAIN_BUFFER_SIZE SZ_32K + +struct ti_csi2rx_fmt { + u32 fourcc; /* Four character code. */ + u32 code; /* Mbus code. */ + u32 csi_dt; /* CSI Data type. */ + u8 bpp; /* Bits per pixel. */ + u8 size; /* Data size shift when unpacking. */ +}; + +struct ti_csi2rx_buffer { + /* Common v4l2 buffer. Must be first. */ + struct vb2_v4l2_buffer vb; + struct list_head list; + struct ti_csi2rx_dev *csi; +}; + +enum ti_csi2rx_dma_state { + TI_CSI2RX_DMA_STOPPED, /* Streaming not started yet. */ + TI_CSI2RX_DMA_IDLE, /* Streaming but no pending DMA operation. */ + TI_CSI2RX_DMA_ACTIVE, /* Streaming and pending DMA operation. */ +}; + +struct ti_csi2rx_dma { + /* Protects all fields in this struct. */ + spinlock_t lock; + struct dma_chan *chan; + /* Buffers queued to the driver, waiting to be processed by DMA. */ + struct list_head queue; + enum ti_csi2rx_dma_state state; + /* + * Queue of buffers submitted to DMA engine. + */ + struct list_head submitted; + /* Buffer to drain stale data from PSI-L endpoint */ + struct { + void *vaddr; + dma_addr_t paddr; + size_t len; + } drain; +}; + +struct ti_csi2rx_dev { + struct device *dev; + void __iomem *shim; + struct v4l2_device v4l2_dev; + struct video_device vdev; + struct media_device mdev; + struct media_pipeline pipe; + struct media_pad pad; + struct v4l2_async_notifier notifier; + struct v4l2_subdev *source; + struct vb2_queue vidq; + struct mutex mutex; /* To serialize ioctls. */ + struct v4l2_format v_fmt; + struct ti_csi2rx_dma dma; + u32 sequence; +}; + +static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = { + { + .fourcc = V4L2_PIX_FMT_YUYV, + .code = MEDIA_BUS_FMT_YUYV8_1X16, + .csi_dt = MIPI_CSI2_DT_YUV422_8B, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_UYVY, + .code = MEDIA_BUS_FMT_UYVY8_1X16, + .csi_dt = MIPI_CSI2_DT_YUV422_8B, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_YVYU, + .code = MEDIA_BUS_FMT_YVYU8_1X16, + .csi_dt = MIPI_CSI2_DT_YUV422_8B, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_VYUY, + .code = MEDIA_BUS_FMT_VYUY8_1X16, + .csi_dt = MIPI_CSI2_DT_YUV422_8B, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR8, + .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .csi_dt = MIPI_CSI2_DT_RAW8, + .bpp = 8, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG8, + .code = MEDIA_BUS_FMT_SGBRG8_1X8, + .csi_dt = MIPI_CSI2_DT_RAW8, + .bpp = 8, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG8, + .code = MEDIA_BUS_FMT_SGRBG8_1X8, + .csi_dt = MIPI_CSI2_DT_RAW8, + .bpp = 8, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB8, + .code = MEDIA_BUS_FMT_SRGGB8_1X8, + .csi_dt = MIPI_CSI2_DT_RAW8, + .bpp = 8, + .size = SHIM_DMACNTX_SIZE_8, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR10, + .code = MEDIA_BUS_FMT_SBGGR10_1X10, + .csi_dt = MIPI_CSI2_DT_RAW10, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_16, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG10, + .code = MEDIA_BUS_FMT_SGBRG10_1X10, + .csi_dt = MIPI_CSI2_DT_RAW10, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_16, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG10, + .code = MEDIA_BUS_FMT_SGRBG10_1X10, + .csi_dt = MIPI_CSI2_DT_RAW10, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_16, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB10, + .code = MEDIA_BUS_FMT_SRGGB10_1X10, + .csi_dt = MIPI_CSI2_DT_RAW10, + .bpp = 16, + .size = SHIM_DMACNTX_SIZE_16, + }, + + /* More formats can be supported but they are not listed for now. */ +}; + +/* Forward declaration needed by ti_csi2rx_dma_callback. */ +static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, + struct ti_csi2rx_buffer *buf); + +static const struct ti_csi2rx_fmt *find_format_by_fourcc(u32 pixelformat) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ti_csi2rx_formats); i++) { + if (ti_csi2rx_formats[i].fourcc == pixelformat) + return &ti_csi2rx_formats[i]; + } + + return NULL; +} + +static const struct ti_csi2rx_fmt *find_format_by_code(u32 code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ti_csi2rx_formats); i++) { + if (ti_csi2rx_formats[i].code == code) + return &ti_csi2rx_formats[i]; + } + + return NULL; +} + +static void ti_csi2rx_fill_fmt(const struct ti_csi2rx_fmt *csi_fmt, + struct v4l2_format *v4l2_fmt) +{ + struct v4l2_pix_format *pix = &v4l2_fmt->fmt.pix; + unsigned int pixels_in_word; + + pixels_in_word = PSIL_WORD_SIZE_BYTES * 8 / csi_fmt->bpp; + + /* Clamp width and height to sensible maximums (16K x 16K) */ + pix->width = clamp_t(unsigned int, pix->width, + pixels_in_word, + MAX_WIDTH_BYTES * 8 / csi_fmt->bpp); + pix->height = clamp_t(unsigned int, pix->height, 1, MAX_HEIGHT_LINES); + + /* Width should be a multiple of transfer word-size */ + pix->width = rounddown(pix->width, pixels_in_word); + + v4l2_fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + pix->pixelformat = csi_fmt->fourcc; + pix->bytesperline = pix->width * (csi_fmt->bpp / 8); + pix->sizeimage = pix->bytesperline * pix->height; +} + +static int ti_csi2rx_querycap(struct file *file, void *priv, + struct v4l2_capability *cap) +{ + strscpy(cap->driver, TI_CSI2RX_MODULE_NAME, sizeof(cap->driver)); + strscpy(cap->card, TI_CSI2RX_MODULE_NAME, sizeof(cap->card)); + + return 0; +} + +static int ti_csi2rx_enum_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_fmtdesc *f) +{ + const struct ti_csi2rx_fmt *fmt = NULL; + + if (f->mbus_code) { + /* 1-to-1 mapping between bus formats and pixel formats */ + if (f->index > 0) + return -EINVAL; + + fmt = find_format_by_code(f->mbus_code); + } else { + if (f->index >= ARRAY_SIZE(ti_csi2rx_formats)) + return -EINVAL; + + fmt = &ti_csi2rx_formats[f->index]; + } + + if (!fmt) + return -EINVAL; + + f->pixelformat = fmt->fourcc; + memset(f->reserved, 0, sizeof(f->reserved)); + f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + return 0; +} + +static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov, + struct v4l2_format *f) +{ + struct ti_csi2rx_dev *csi = video_drvdata(file); + + *f = csi->v_fmt; + + return 0; +} + +static int ti_csi2rx_try_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) +{ + const struct ti_csi2rx_fmt *fmt; + + /* + * Default to the first format if the requested pixel format code isn't + * supported. + */ + fmt = find_format_by_fourcc(f->fmt.pix.pixelformat); + if (!fmt) + fmt = &ti_csi2rx_formats[0]; + + /* Interlaced formats are not supported. */ + f->fmt.pix.field = V4L2_FIELD_NONE; + + ti_csi2rx_fill_fmt(fmt, f); + + return 0; +} + +static int ti_csi2rx_s_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) +{ + struct ti_csi2rx_dev *csi = video_drvdata(file); + struct vb2_queue *q = &csi->vidq; + int ret; + + if (vb2_is_busy(q)) + return -EBUSY; + + ret = ti_csi2rx_try_fmt_vid_cap(file, priv, f); + if (ret < 0) + return ret; + + csi->v_fmt = *f; + + return 0; +} + +static int ti_csi2rx_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) +{ + const struct ti_csi2rx_fmt *fmt; + unsigned int pixels_in_word; + + fmt = find_format_by_fourcc(fsize->pixel_format); + if (!fmt || fsize->index != 0) + return -EINVAL; + + /* + * Number of pixels in one PSI-L word. The transfer happens in multiples + * of PSI-L word sizes. + */ + pixels_in_word = PSIL_WORD_SIZE_BYTES * 8 / fmt->bpp; + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + fsize->stepwise.min_width = pixels_in_word; + fsize->stepwise.max_width = rounddown(MAX_WIDTH_BYTES * 8 / fmt->bpp, + pixels_in_word); + fsize->stepwise.step_width = pixels_in_word; + fsize->stepwise.min_height = 1; + fsize->stepwise.max_height = MAX_HEIGHT_LINES; + fsize->stepwise.step_height = 1; + + return 0; +} + +static const struct v4l2_ioctl_ops csi_ioctl_ops = { + .vidioc_querycap = ti_csi2rx_querycap, + .vidioc_enum_fmt_vid_cap = ti_csi2rx_enum_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = ti_csi2rx_try_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = ti_csi2rx_g_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = ti_csi2rx_s_fmt_vid_cap, + .vidioc_enum_framesizes = ti_csi2rx_enum_framesizes, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, +}; + +static const struct v4l2_file_operations csi_fops = { + .owner = THIS_MODULE, + .open = v4l2_fh_open, + .release = vb2_fop_release, + .read = vb2_fop_read, + .poll = vb2_fop_poll, + .unlocked_ioctl = video_ioctl2, + .mmap = vb2_fop_mmap, +}; + +static int csi_async_notifier_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *subdev, + struct v4l2_async_connection *asc) +{ + struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev); + + csi->source = subdev; + + return 0; +} + +static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier) +{ + struct ti_csi2rx_dev *csi = dev_get_drvdata(notifier->v4l2_dev->dev); + struct video_device *vdev = &csi->vdev; + int ret; + + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret) + return ret; + + ret = v4l2_create_fwnode_links_to_pad(csi->source, &csi->pad, + MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); + + if (ret) { + video_unregister_device(vdev); + return ret; + } + + ret = v4l2_device_register_subdev_nodes(&csi->v4l2_dev); + if (ret) + video_unregister_device(vdev); + + return ret; +} + +static const struct v4l2_async_notifier_operations csi_async_notifier_ops = { + .bound = csi_async_notifier_bound, + .complete = csi_async_notifier_complete, +}; + +static int ti_csi2rx_notifier_register(struct ti_csi2rx_dev *csi) +{ + struct fwnode_handle *fwnode; + struct v4l2_async_connection *asc; + struct device_node *node; + int ret; + + node = of_get_child_by_name(csi->dev->of_node, "csi-bridge"); + if (!node) + return -EINVAL; + + fwnode = of_fwnode_handle(node); + if (!fwnode) { + of_node_put(node); + return -EINVAL; + } + + v4l2_async_nf_init(&csi->notifier, &csi->v4l2_dev); + csi->notifier.ops = &csi_async_notifier_ops; + + asc = v4l2_async_nf_add_fwnode(&csi->notifier, fwnode, + struct v4l2_async_connection); + of_node_put(node); + if (IS_ERR(asc)) { + v4l2_async_nf_cleanup(&csi->notifier); + return PTR_ERR(asc); + } + + ret = v4l2_async_nf_register(&csi->notifier); + if (ret) { + v4l2_async_nf_cleanup(&csi->notifier); + return ret; + } + + return 0; +} + +static void ti_csi2rx_setup_shim(struct ti_csi2rx_dev *csi) +{ + const struct ti_csi2rx_fmt *fmt; + unsigned int reg; + + fmt = find_format_by_fourcc(csi->v_fmt.fmt.pix.pixelformat); + + /* De-assert the pixel interface reset. */ + reg = SHIM_CNTL_PIX_RST; + writel(reg, csi->shim + SHIM_CNTL); + + reg = SHIM_DMACNTX_EN; + reg |= FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); + + /* + * The hardware assumes incoming YUV422 8-bit data on MIPI CSI2 bus + * follows the spec and is packed in the order U0 -> Y0 -> V0 -> Y1 -> + * ... + * + * There is an option to swap the bytes around before storing in + * memory, to achieve different pixel formats: + * + * Byte3 <----------- Byte0 + * [ Y1 ][ V0 ][ Y0 ][ U0 ] MODE 11 + * [ Y1 ][ U0 ][ Y0 ][ V0 ] MODE 10 + * [ V0 ][ Y1 ][ U0 ][ Y0 ] MODE 01 + * [ U0 ][ Y1 ][ V0 ][ Y0 ] MODE 00 + * + * We don't have any requirement to change pixelformat from what is + * coming from the source, so we keep it in MODE 11, which does not + * swap any bytes when storing in memory. + */ + switch (fmt->fourcc) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + reg |= FIELD_PREP(SHIM_DMACNTX_YUV422, + SHIM_DMACNTX_YUV422_MODE_11); + break; + default: + /* Ignore if not YUV 4:2:2 */ + break; + } + + reg |= FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size); + + writel(reg, csi->shim + SHIM_DMACNTX); + + reg = FIELD_PREP(SHIM_PSI_CFG0_SRC_TAG, 0) | + FIELD_PREP(SHIM_PSI_CFG0_DST_TAG, 0); + writel(reg, csi->shim + SHIM_PSI_CFG0); +} + +static void ti_csi2rx_drain_callback(void *param) +{ + struct completion *drain_complete = param; + + complete(drain_complete); +} + +/* + * Drain the stale data left at the PSI-L endpoint. + * + * This might happen if no buffers are queued in time but source is still + * streaming. In multi-stream scenarios this can happen when one stream is + * stopped but other is still streaming, and thus module-level pixel reset is + * not asserted. + * + * To prevent that stale data corrupting the subsequent transactions, it is + * required to issue DMA requests to drain it out. + */ +static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) +{ + struct dma_async_tx_descriptor *desc; + struct completion drain_complete; + dma_cookie_t cookie; + int ret; + + init_completion(&drain_complete); + + desc = dmaengine_prep_slave_single(csi->dma.chan, csi->dma.drain.paddr, + csi->dma.drain.len, DMA_DEV_TO_MEM, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + if (!desc) { + ret = -EIO; + goto out; + } + + desc->callback = ti_csi2rx_drain_callback; + desc->callback_param = &drain_complete; + + cookie = dmaengine_submit(desc); + ret = dma_submit_error(cookie); + if (ret) + goto out; + + dma_async_issue_pending(csi->dma.chan); + + if (!wait_for_completion_timeout(&drain_complete, + msecs_to_jiffies(DRAIN_TIMEOUT_MS))) { + dmaengine_terminate_sync(csi->dma.chan); + dev_dbg(csi->dev, "DMA transfer timed out for drain buffer\n"); + ret = -ETIMEDOUT; + goto out; + } +out: + return ret; +} + +static void ti_csi2rx_dma_callback(void *param) +{ + struct ti_csi2rx_buffer *buf = param; + struct ti_csi2rx_dev *csi = buf->csi; + struct ti_csi2rx_dma *dma = &csi->dma; + unsigned long flags; + + /* + * TODO: Derive the sequence number from the CSI2RX frame number + * hardware monitor registers. + */ + buf->vb.vb2_buf.timestamp = ktime_get_ns(); + buf->vb.sequence = csi->sequence++; + + spin_lock_irqsave(&dma->lock, flags); + + WARN_ON(!list_is_first(&buf->list, &dma->submitted)); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + list_del(&buf->list); + + /* If there are more buffers to process then start their transfer. */ + while (!list_empty(&dma->queue)) { + buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + + if (ti_csi2rx_start_dma(csi, buf)) { + dev_err(csi->dev, "Failed to queue the next buffer for DMA\n"); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + } else { + list_move_tail(&buf->list, &dma->submitted); + } + } + + if (list_empty(&dma->submitted)) + dma->state = TI_CSI2RX_DMA_IDLE; + + spin_unlock_irqrestore(&dma->lock, flags); +} + +static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, + struct ti_csi2rx_buffer *buf) +{ + unsigned long addr; + struct dma_async_tx_descriptor *desc; + size_t len = csi->v_fmt.fmt.pix.sizeimage; + dma_cookie_t cookie; + int ret = 0; + + addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0); + desc = dmaengine_prep_slave_single(csi->dma.chan, addr, len, + DMA_DEV_TO_MEM, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + if (!desc) + return -EIO; + + desc->callback = ti_csi2rx_dma_callback; + desc->callback_param = buf; + + cookie = dmaengine_submit(desc); + ret = dma_submit_error(cookie); + if (ret) + return ret; + + dma_async_issue_pending(csi->dma.chan); + + return 0; +} + +static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *csi) +{ + struct ti_csi2rx_dma *dma = &csi->dma; + enum ti_csi2rx_dma_state state; + unsigned long flags; + int ret; + + spin_lock_irqsave(&dma->lock, flags); + state = csi->dma.state; + dma->state = TI_CSI2RX_DMA_STOPPED; + spin_unlock_irqrestore(&dma->lock, flags); + + if (state != TI_CSI2RX_DMA_STOPPED) { + /* + * Normal DMA termination does not clean up pending data on + * the endpoint if multiple streams are running and only one + * is stopped, as the module-level pixel reset cannot be + * enforced before terminating DMA. + */ + ret = ti_csi2rx_drain_dma(csi); + if (ret && ret != -ETIMEDOUT) + dev_warn(csi->dev, + "Failed to drain DMA. Next frame might be bogus\n"); + } + + ret = dmaengine_terminate_sync(csi->dma.chan); + if (ret) + dev_err(csi->dev, "Failed to stop DMA: %d\n", ret); +} + +static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_dev *csi, + enum vb2_buffer_state state) +{ + struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_buffer *buf, *tmp; + unsigned long flags; + + spin_lock_irqsave(&dma->lock, flags); + list_for_each_entry_safe(buf, tmp, &csi->dma.queue, list) { + list_del(&buf->list); + vb2_buffer_done(&buf->vb.vb2_buf, state); + } + list_for_each_entry_safe(buf, tmp, &csi->dma.submitted, list) { + list_del(&buf->list); + vb2_buffer_done(&buf->vb.vb2_buf, state); + } + spin_unlock_irqrestore(&dma->lock, flags); +} + +static int ti_csi2rx_queue_setup(struct vb2_queue *q, unsigned int *nbuffers, + unsigned int *nplanes, unsigned int sizes[], + struct device *alloc_devs[]) +{ + struct ti_csi2rx_dev *csi = vb2_get_drv_priv(q); + unsigned int size = csi->v_fmt.fmt.pix.sizeimage; + + if (*nplanes) { + if (sizes[0] < size) + return -EINVAL; + size = sizes[0]; + } + + *nplanes = 1; + sizes[0] = size; + + return 0; +} + +static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb) +{ + struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vb->vb2_queue); + unsigned long size = csi->v_fmt.fmt.pix.sizeimage; + + if (vb2_plane_size(vb, 0) < size) { + dev_err(csi->dev, "Data will not fit into plane\n"); + return -EINVAL; + } + + vb2_set_plane_payload(vb, 0, size); + return 0; +} + +static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) +{ + struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vb->vb2_queue); + struct ti_csi2rx_buffer *buf; + struct ti_csi2rx_dma *dma = &csi->dma; + bool restart_dma = false; + unsigned long flags = 0; + int ret; + + buf = container_of(vb, struct ti_csi2rx_buffer, vb.vb2_buf); + buf->csi = csi; + + spin_lock_irqsave(&dma->lock, flags); + /* + * Usually the DMA callback takes care of queueing the pending buffers. + * But if DMA has stalled due to lack of buffers, restart it now. + */ + if (dma->state == TI_CSI2RX_DMA_IDLE) { + /* + * Do not restart DMA with the lock held because + * ti_csi2rx_drain_dma() might block for completion. + * There won't be a race on queueing DMA anyway since the + * callback is not being fired. + */ + restart_dma = true; + dma->state = TI_CSI2RX_DMA_ACTIVE; + } else { + list_add_tail(&buf->list, &dma->queue); + } + spin_unlock_irqrestore(&dma->lock, flags); + + if (restart_dma) { + /* + * Once frames start dropping, some data gets stuck in the DMA + * pipeline somewhere. So the first DMA transfer after frame + * drops gives a partial frame. This is obviously not useful to + * the application and will only confuse it. Issue a DMA + * transaction to drain that up. + */ + ret = ti_csi2rx_drain_dma(csi); + if (ret && ret != -ETIMEDOUT) + dev_warn(csi->dev, + "Failed to drain DMA. Next frame might be bogus\n"); + + ret = ti_csi2rx_start_dma(csi, buf); + if (ret) { + dev_err(csi->dev, "Failed to start DMA: %d\n", ret); + spin_lock_irqsave(&dma->lock, flags); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + dma->state = TI_CSI2RX_DMA_IDLE; + spin_unlock_irqrestore(&dma->lock, flags); + } else { + spin_lock_irqsave(&dma->lock, flags); + list_add_tail(&buf->list, &dma->submitted); + spin_unlock_irqrestore(&dma->lock, flags); + } + } +} + +static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) +{ + struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vq); + struct ti_csi2rx_dma *dma = &csi->dma; + struct ti_csi2rx_buffer *buf; + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&dma->lock, flags); + if (list_empty(&dma->queue)) + ret = -EIO; + spin_unlock_irqrestore(&dma->lock, flags); + if (ret) + return ret; + + ret = video_device_pipeline_start(&csi->vdev, &csi->pipe); + if (ret) + goto err; + + ti_csi2rx_setup_shim(csi); + + csi->sequence = 0; + + spin_lock_irqsave(&dma->lock, flags); + buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + + ret = ti_csi2rx_start_dma(csi, buf); + if (ret) { + dev_err(csi->dev, "Failed to start DMA: %d\n", ret); + spin_unlock_irqrestore(&dma->lock, flags); + goto err_pipeline; + } + + list_move_tail(&buf->list, &dma->submitted); + dma->state = TI_CSI2RX_DMA_ACTIVE; + spin_unlock_irqrestore(&dma->lock, flags); + + ret = v4l2_subdev_call(csi->source, video, s_stream, 1); + if (ret) + goto err_dma; + + return 0; + +err_dma: + ti_csi2rx_stop_dma(csi); +err_pipeline: + video_device_pipeline_stop(&csi->vdev); + writel(0, csi->shim + SHIM_CNTL); + writel(0, csi->shim + SHIM_DMACNTX); +err: + ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_QUEUED); + return ret; +} + +static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) +{ + struct ti_csi2rx_dev *csi = vb2_get_drv_priv(vq); + int ret; + + video_device_pipeline_stop(&csi->vdev); + + writel(0, csi->shim + SHIM_CNTL); + writel(0, csi->shim + SHIM_DMACNTX); + + ret = v4l2_subdev_call(csi->source, video, s_stream, 0); + if (ret) + dev_err(csi->dev, "Failed to stop subdev stream\n"); + + ti_csi2rx_stop_dma(csi); + ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_ERROR); +} + +static const struct vb2_ops csi_vb2_qops = { + .queue_setup = ti_csi2rx_queue_setup, + .buf_prepare = ti_csi2rx_buffer_prepare, + .buf_queue = ti_csi2rx_buffer_queue, + .start_streaming = ti_csi2rx_start_streaming, + .stop_streaming = ti_csi2rx_stop_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, +}; + +static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi) +{ + struct vb2_queue *q = &csi->vidq; + int ret; + + q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + q->io_modes = VB2_MMAP | VB2_DMABUF; + q->drv_priv = csi; + q->buf_struct_size = sizeof(struct ti_csi2rx_buffer); + q->ops = &csi_vb2_qops; + q->mem_ops = &vb2_dma_contig_memops; + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + q->dev = dmaengine_get_dma_device(csi->dma.chan); + q->lock = &csi->mutex; + q->min_buffers_needed = 1; + + ret = vb2_queue_init(q); + if (ret) + return ret; + + csi->vdev.queue = q; + + return 0; +} + +static int ti_csi2rx_link_validate(struct media_link *link) +{ + struct media_entity *entity = link->sink->entity; + struct video_device *vdev = media_entity_to_video_device(entity); + struct ti_csi2rx_dev *csi = container_of(vdev, struct ti_csi2rx_dev, vdev); + struct v4l2_pix_format *csi_fmt = &csi->v_fmt.fmt.pix; + struct v4l2_subdev_format source_fmt = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = link->source->index, + }; + const struct ti_csi2rx_fmt *ti_fmt; + int ret; + + ret = v4l2_subdev_call_state_active(csi->source, pad, + get_fmt, &source_fmt); + if (ret) + return ret; + + if (source_fmt.format.width != csi_fmt->width) { + dev_dbg(csi->dev, "Width does not match (source %u, sink %u)\n", + source_fmt.format.width, csi_fmt->width); + return -EPIPE; + } + + if (source_fmt.format.height != csi_fmt->height) { + dev_dbg(csi->dev, "Height does not match (source %u, sink %u)\n", + source_fmt.format.height, csi_fmt->height); + return -EPIPE; + } + + if (source_fmt.format.field != csi_fmt->field && + csi_fmt->field != V4L2_FIELD_NONE) { + dev_dbg(csi->dev, "Field does not match (source %u, sink %u)\n", + source_fmt.format.field, csi_fmt->field); + return -EPIPE; + } + + ti_fmt = find_format_by_code(source_fmt.format.code); + if (!ti_fmt) { + dev_dbg(csi->dev, "Media bus format 0x%x not supported\n", + source_fmt.format.code); + return -EPIPE; + } + + if (ti_fmt->fourcc != csi_fmt->pixelformat) { + dev_dbg(csi->dev, + "Cannot transform source fmt 0x%x to sink fmt 0x%x\n", + ti_fmt->fourcc, csi_fmt->pixelformat); + return -EPIPE; + } + + return 0; +} + +static const struct media_entity_operations ti_csi2rx_video_entity_ops = { + .link_validate = ti_csi2rx_link_validate, +}; + +static int ti_csi2rx_init_dma(struct ti_csi2rx_dev *csi) +{ + struct dma_slave_config cfg = { + .src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES, + }; + int ret; + + INIT_LIST_HEAD(&csi->dma.queue); + INIT_LIST_HEAD(&csi->dma.submitted); + spin_lock_init(&csi->dma.lock); + + csi->dma.state = TI_CSI2RX_DMA_STOPPED; + + csi->dma.chan = dma_request_chan(csi->dev, "rx0"); + if (IS_ERR(csi->dma.chan)) + return PTR_ERR(csi->dma.chan); + + ret = dmaengine_slave_config(csi->dma.chan, &cfg); + if (ret) { + dma_release_channel(csi->dma.chan); + return ret; + } + + csi->dma.drain.len = DRAIN_BUFFER_SIZE; + csi->dma.drain.vaddr = dma_alloc_coherent(csi->dev, csi->dma.drain.len, + &csi->dma.drain.paddr, + GFP_KERNEL); + if (!csi->dma.drain.vaddr) + return -ENOMEM; + + return 0; +} + +static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) +{ + struct media_device *mdev = &csi->mdev; + struct video_device *vdev = &csi->vdev; + const struct ti_csi2rx_fmt *fmt; + struct v4l2_pix_format *pix_fmt = &csi->v_fmt.fmt.pix; + int ret; + + fmt = find_format_by_fourcc(V4L2_PIX_FMT_UYVY); + if (!fmt) + return -EINVAL; + + pix_fmt->width = 640; + pix_fmt->height = 480; + pix_fmt->field = V4L2_FIELD_NONE; + pix_fmt->colorspace = V4L2_COLORSPACE_SRGB; + pix_fmt->ycbcr_enc = V4L2_YCBCR_ENC_601, + pix_fmt->quantization = V4L2_QUANTIZATION_LIM_RANGE, + pix_fmt->xfer_func = V4L2_XFER_FUNC_SRGB, + + ti_csi2rx_fill_fmt(fmt, &csi->v_fmt); + + mdev->dev = csi->dev; + mdev->hw_revision = 1; + strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model)); + + media_device_init(mdev); + + strscpy(vdev->name, TI_CSI2RX_MODULE_NAME, sizeof(vdev->name)); + vdev->v4l2_dev = &csi->v4l2_dev; + vdev->vfl_dir = VFL_DIR_RX; + vdev->fops = &csi_fops; + vdev->ioctl_ops = &csi_ioctl_ops; + vdev->release = video_device_release_empty; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; + vdev->lock = &csi->mutex; + video_set_drvdata(vdev, csi); + + csi->pad.flags = MEDIA_PAD_FL_SINK; + vdev->entity.ops = &ti_csi2rx_video_entity_ops; + ret = media_entity_pads_init(&csi->vdev.entity, 1, &csi->pad); + if (ret) + return ret; + + csi->v4l2_dev.mdev = mdev; + + ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); + if (ret) + return ret; + + ret = media_device_register(mdev); + if (ret) { + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(mdev); + return ret; + } + + return 0; +} + +static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_dev *csi) +{ + dma_free_coherent(csi->dev, csi->dma.drain.len, + csi->dma.drain.vaddr, csi->dma.drain.paddr); + csi->dma.drain.vaddr = NULL; + dma_release_channel(csi->dma.chan); +} + +static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) +{ + media_device_unregister(&csi->mdev); + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(&csi->mdev); +} + +static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi) +{ + v4l2_async_nf_unregister(&csi->notifier); + v4l2_async_nf_cleanup(&csi->notifier); +} + +static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi) +{ + vb2_queue_release(&csi->vidq); +} + +static int ti_csi2rx_probe(struct platform_device *pdev) +{ + struct ti_csi2rx_dev *csi; + struct resource *res; + int ret; + + csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); + if (!csi) + return -ENOMEM; + + csi->dev = &pdev->dev; + platform_set_drvdata(pdev, csi); + + mutex_init(&csi->mutex); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + csi->shim = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(csi->shim)) { + ret = PTR_ERR(csi->shim); + goto err_mutex; + } + + ret = ti_csi2rx_init_dma(csi); + if (ret) + goto err_mutex; + + ret = ti_csi2rx_v4l2_init(csi); + if (ret) + goto err_dma; + + ret = ti_csi2rx_init_vb2q(csi); + if (ret) + goto err_v4l2; + + ret = ti_csi2rx_notifier_register(csi); + if (ret) + goto err_vb2q; + + ret = of_platform_populate(csi->dev->of_node, NULL, NULL, csi->dev); + if (ret) { + dev_err(csi->dev, "Failed to create children: %d\n", ret); + goto err_subdev; + } + + return 0; + +err_subdev: + ti_csi2rx_cleanup_subdev(csi); +err_vb2q: + ti_csi2rx_cleanup_vb2q(csi); +err_v4l2: + ti_csi2rx_cleanup_v4l2(csi); +err_dma: + ti_csi2rx_cleanup_dma(csi); +err_mutex: + mutex_destroy(&csi->mutex); + return ret; +} + +static int ti_csi2rx_remove(struct platform_device *pdev) +{ + struct ti_csi2rx_dev *csi = platform_get_drvdata(pdev); + + video_unregister_device(&csi->vdev); + + ti_csi2rx_cleanup_vb2q(csi); + ti_csi2rx_cleanup_subdev(csi); + ti_csi2rx_cleanup_v4l2(csi); + ti_csi2rx_cleanup_dma(csi); + + mutex_destroy(&csi->mutex); + + return 0; +} + +static const struct of_device_id ti_csi2rx_of_match[] = { + { .compatible = "ti,j721e-csi2rx-shim", }, + { }, +}; +MODULE_DEVICE_TABLE(of, ti_csi2rx_of_match); + +static struct platform_driver ti_csi2rx_pdrv = { + .probe = ti_csi2rx_probe, + .remove = ti_csi2rx_remove, + .driver = { + .name = TI_CSI2RX_MODULE_NAME, + .of_match_table = ti_csi2rx_of_match, + }, +}; + +module_platform_driver(ti_csi2rx_pdrv); + +MODULE_DESCRIPTION("TI J721E CSI2 RX Driver"); +MODULE_AUTHOR("Jai Luthra "); +MODULE_LICENSE("GPL");