From patchwork Tue Dec 15 11:18:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mirela Rabulea OSS X-Patchwork-Id: 344115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE028C4361B for ; Tue, 15 Dec 2020 11:25:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A047222258 for ; Tue, 15 Dec 2020 11:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgLOLU4 (ORCPT ); Tue, 15 Dec 2020 06:20:56 -0500 Received: from mail-eopbgr130072.outbound.protection.outlook.com ([40.107.13.72]:15078 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728750AbgLOLUx (ORCPT ); Tue, 15 Dec 2020 06:20:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C6WAwM7gTnVqo2GYHpUsG99DFDnYsqWYXM1s30zcyYYVfIwc6OCBc/ph9Op4t7oD36BVMwXlga2vUdA10/AW3SEybjRqW/GtoFxcx5YZg6+dHDnR8N8KMhdwuHNDfeSHxvZ5pXjgjn2epwWDYGU189H59ioPAebNJy/W00npeTEk9VLil3Uxt1UNES+brf7A8QQKcC+RRFQyeQ8jHhDpPPJ+PYiM10UMKf9mqhVrIPm5oTZ9tQflfp3pNgDPgGetq8/sg0ATKZkOUiMijYtYqMXxuF2Jxloxp4kUrdKt9PLJB0scbJlovFALyU/YSKQCblVH9G+rmcY3HC5VlrMqXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k0V1zdrLbvgQAGNAXomG7Gqu/+o5i3YRd9YCbapA6M4=; b=dqbxT5eqnqLOmjGWMo9TLo5Qw7XK1+dzO7OT8+4fSy2/RZ8cQGLrtw01vs9dgSHGrh09qrVq47GHvv7pSKEHbByYX0vHbsEy7wN0dEhEfzFjRGkdUfOYzbNqPVMXWlwiBoU+5VWsfZoooCUgQnRPqn8XCxxd1J6xEgkf8ist/z9dSDOh6CzBSgqdrogEAJIEpoUGDzH0ijmAfo9uN8JL3nZOuL+I3yrHez90g3zFap/PavceXlO78BY02Rl+VkzlVT8y0Y3zGcBEZ/rX5rDYE2W5UdJ2JpRV0Oqlt+aRBy+RbA50/AHIQ6hJknf8SSQAUocLvJYThEoIoUYwKV71Ag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k0V1zdrLbvgQAGNAXomG7Gqu/+o5i3YRd9YCbapA6M4=; b=aD7cZSeXPsgF0No1b5EFqent36JG0v5bN6a7fHpP4MygXI/XN4wN8aRoEjBetVHa/1C1Q0YV7D3gdXSjUmwMuJ4y4rQFfqTsY9sSG9UfXDiulY+pVeWsesXc2+m20Un3FUWS75JpoEEcRKJrLUYcdIgysmXnLx7fqikVmCsBJ4c= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) by AM5PR0402MB2737.eurprd04.prod.outlook.com (2603:10a6:203:95::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Tue, 15 Dec 2020 11:19:14 +0000 Received: from AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9]) by AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9%6]) with mapi id 15.20.3654.024; Tue, 15 Dec 2020 11:19:14 +0000 From: "Mirela Rabulea (OSS)" To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, shawnguo@kernel.org, robh+dt@kernel.org, p.zabel@pengutronix.de Cc: paul.kocialkowski@bootlin.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, aisheng.dong@nxp.com, daniel.baluta@nxp.com, robert.chiras@nxp.com, laurentiu.palcu@nxp.com, mark.rutland@arm.com, devicetree@vger.kernel.org, ezequiel@collabora.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, dafna.hirschfeld@collabora.com, Mirela Rabulea Subject: [PATCH v6 2/9] media: dt-bindings: Add bindings for i.MX8QXP/QM JPEG driver Date: Tue, 15 Dec 2020 13:18:36 +0200 Message-Id: <20201215111843.30269-3-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> References: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> X-Originating-IP: [79.115.51.151] X-ClientProxiedBy: VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) To AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1664-134.ea.freescale.net (79.115.51.151) by VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 11:19:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 23ce50d4-97ae-4819-c1b2-08d8a0eb417a X-MS-TrafficTypeDiagnostic: AM5PR0402MB2737: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r3wax5oOTegX16Zut6uiEvUDSZKGRlPA+fDahOeEYxZrlE5WoRD+p4wTijP1rBde0YObgCMqwsV4UlREK9jpuOLghCE/2SW76S8GSHAy5N553NwNTkA9PZ9X/aS1spEiGTAiuxzqPEaVWQ7eQQx8DtW+D1r6hkryPdEt8GrpOn4b90sd9KNOpwzQLmHuhqSMmzTl8XnMQ59EEWCzQImii2RimKpEYXcZG7vwU2dMXaU20pih4uoNzH4J4hj23WZB1Cd6O3NLl5Z8zjpZ6pbkNE/kFbzDk2C8UYVvGSNfFIh7lPRaFajXT0p4GRo3ssI41/9G1heVofqLvsT0EC+sPOSJIyxiE6SWLVV9KVAJ6toF7uP0CYc1Z0Nugo2E9kI8l8Rk5n1XhmtoN+G1wuzsBw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR04MB3137.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6666004)(2616005)(16526019)(8936002)(52116002)(2906002)(1076003)(956004)(66946007)(6486002)(66556008)(66476007)(498600001)(6512007)(86362001)(966005)(8676002)(7416002)(6506007)(186003)(4326008)(26005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ICJDwJb1VhuUNiobpnKrJL7mW4cv3AogdTn7X39+t2gxRq2oPrxsG5yZhqKrVHHdCEyUd3pc/7R7YNpmUvS5xtaNIZa3NEFMH24B/z8Ltz8Uj5nWTWDQaHLHt0Ve4xMomkh2KJV5G2rqwjF3gfHPee6Tylaxb8wHqhyWSANh9E/4/hrcZwcWKEeCuNKAxYWGFl2NlWtlwsaNDU2Koq50OoHeEaIM+PfO6IX5qB0+8/ZIyuO0xEi7z/O8OIERRxvW5syd4LxpyAFSNSzkwkA4/E8G1ek7MBHA4UMV545k338nZ9RZMgDdQ0UBnGOljOFb4NTDX9MDw5FBNBFZbIZlRclUSGHR3NwkusD0nSVL3hsJzWjLzlg922G3ZHw6673EPKk8VDnSXZSr06ZwWLXdp0GMU39jlJfoCXw4JLhS5k5C4jaVty4tYZlWKXgVhKTNPii0drnMFBwIbBpPlnMibYWrwjQlaUcFYHekSlrDdzpRe85wJIIZ2slzxRCfZS9ABFZo+zFfqEVn9Sr960owY0WOaH5dPL/6W5+XOhSNM7Xvl1ilJkEW9LPR+i29I7Slgscmkwpt+3+rKG/SHxEVMpaiaohQ8ZyrU7+9WMLlguYxpjAoPsVS+k3rF/jgJ28MJ5emdWqkYVOgYSq//Idb5V+YTGuZ2uvv5/VUIwRPxRkxepcIgRCcEes5bqWx7alWWwzNwyw6wv9KQSP1PwJ+6+NxIomK+vZ6QgcRIx0xHgJ9ELsDmSyvQABHDUYfqFipS0SOnH+dMhxSNwqP1Q1t2K2dZqUyfITJ9odYBG4oI2YvKNOfD3XSG4YN+RIXtUPx/m/VN+3BcmXiY3UfcBzHhrtX1eiFoW1w19X1la+89ijusS8kmGokawcOB553a9OMk8NWlOnVMRzLKyh2VRIpB+XDCY4VFW6nycguUDLegxav8zyGbQCxFtMxylfEL7jTTw1aRZGcqrLbGD8fK6pxxcqhYXQW+eBM0Qr7JvVTgbpmcISmpCjhx+NH1vd6ujEz X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3137.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 11:19:14.7568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 23ce50d4-97ae-4819-c1b2-08d8a0eb417a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zLNRCs/rsO3pnhJOws6ulLvUY5Efv6rwul1jaWeIgtfqH60UkDL/Lr2MYxLWjvSPEjh5YHRw3SNPxuJj/xjYbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2737 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Mirela Rabulea Add bindings documentation for i.MX8QXP/QM JPEG decoder & encoder driver. Signed-off-by: Mirela Rabulea Reviewed-by: Rob Herring --- Changes in v6: Reviewed-by: Rob Herring .../bindings/media/nxp,imx8-jpeg.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml diff --git a/Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml b/Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml new file mode 100644 index 000000000000..5d13cbb5251b --- /dev/null +++ b/Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/nxp,imx8-jpeg.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX8QXP/QM JPEG decoder/encoder Device Tree Bindings + +maintainers: + - Mirela Rabulea + +description: |- + The JPEG decoder/encoder present in iMX8QXP and iMX8QM SoCs is an + ISO/IEC 10918-1 JPEG standard compliant decoder/encoder, for Baseline + and Extended Sequential DCT modes. + +properties: + compatible: + items: + - enum: + # JPEG decoder + - nxp,imx8qxp-jpgdec + # JPEG encoder + - nxp,imx8qxp-jpgenc + + reg: + maxItems: 1 + + interrupts: + description: | + There are 4 slots available in the IP, which the driver may use + If a certain slot is used, it should have an associated interrupt + The interrupt with index i is assumed to be for slot i + minItems: 1 # At least one slot is needed by the driver + maxItems: 4 # The IP has 4 slots available for use + + power-domains: + description: + List of phandle and PM domain specifier as documented in + Documentation/devicetree/bindings/power/power_domain.txt + minItems: 2 # Wrapper and 1 slot + maxItems: 5 # Wrapper and 4 slots + +required: + - compatible + - reg + - interrupts + - power-domains + +additionalProperties: false + +examples: + - | + #include + #include + + jpegdec: jpegdec@58400000 { + compatible = "nxp,imx8qxp-jpgdec"; + reg = <0x58400000 0x00050000 >; + interrupts = , + , + , + ; + power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>, + <&pd IMX_SC_R_MJPEG_DEC_S0>, + <&pd IMX_SC_R_MJPEG_DEC_S1>, + <&pd IMX_SC_R_MJPEG_DEC_S2>, + <&pd IMX_SC_R_MJPEG_DEC_S3>; + }; + + jpegenc: jpegenc@58450000 { + compatible = "nxp,imx8qxp-jpgenc"; + reg = <0x58450000 0x00050000 >; + interrupts = , + , + , + ; + power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>, + <&pd IMX_SC_R_MJPEG_ENC_S0>, + <&pd IMX_SC_R_MJPEG_ENC_S1>, + <&pd IMX_SC_R_MJPEG_ENC_S2>, + <&pd IMX_SC_R_MJPEG_ENC_S3>; + }; +... From patchwork Tue Dec 15 11:18:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mirela Rabulea OSS X-Patchwork-Id: 344118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 797ACC2BBCA for ; Tue, 15 Dec 2020 11:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 300BD22285 for ; Tue, 15 Dec 2020 11:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728565AbgLOLUz (ORCPT ); Tue, 15 Dec 2020 06:20:55 -0500 Received: from mail-eopbgr130083.outbound.protection.outlook.com ([40.107.13.83]:62016 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728758AbgLOLUs (ORCPT ); Tue, 15 Dec 2020 06:20:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TPovnH6H7drncWsQ32ZjCp8/c0z8mX7zsx13dWPjc3m5E2gLMqBO9Qkz+tVoVYWMMIMCzLI1oyeR4CF0yj0lSrmLmXSsCEvP+gSLRKCW7L0sdlBtKxJskeM1RDSSt5V4CK1nd/2fHwLS2NK8ZqFL8ncEKAbw109E1v0gdHb8G0a7lgb2tBqU73cyWg3vWgxA9iIxjzfunVqaousy5EE5Nz64AuSlmoucrpLTd8NhvJTNW+9cg5fhf4/oCl6qBCioawOjCxiH7hZ1PRoG4NFe5mQH4N0gV1NAmxK58kN6uiDp3VWGdCt+Gz3kqUEs5P/QhUlR5Xj+JUpPrC7flUCgSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R6U87qm3k/1UwuQMLQa0o40T6bNCr1bNRj+NJT1CZds=; b=TL2aDXcK1vPBSLSRPK1k6kb6ZwfR4stlFAfsXXIm9TWFYHVw16g4Fm4HuCKykgAomnXRbR+Dcs6NMXM1XOUaKMYp6r7rjYuxvzYDRp6bq639W5Go2cP9OrkjZ3kDClQnPTXITUbEp7a1IRs0MFcSQOhF4QbQZV7euv2ErcnfUd5pCGmJKfQxcDQd4mRhZqK0Xb6/GQcQdUx5RzjxIYTs3+Gmdl2K20Z9IBadWA2FFuKF+8hkGxNGyKkHe88reIeH92uNRd7JuAXLIvrYKFlH0IfVY4W+IUEDQlElKm73xFYJ715KKY0MKZ5U8vAiLd+VKtW9+1b8Nyzpi4PYNvU2ZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R6U87qm3k/1UwuQMLQa0o40T6bNCr1bNRj+NJT1CZds=; b=UbnRLIhC9nwSjpwT0HnSWIL4sxbCSc5iXpq2hu2KgTGT/VhCkYCv0/MNYyTmsCK6vUqzNfC0o01eMuCOkBJnGBQrC3HcldKJnIg1nSC0LciZ/UVy8CAH+wFlZPeBX2gA+M/gfHg/APREJn/uB6IQziqbkOGHoJDm+c6F9o/tQ0A= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) by AM5PR0402MB2737.eurprd04.prod.outlook.com (2603:10a6:203:95::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Tue, 15 Dec 2020 11:19:26 +0000 Received: from AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9]) by AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9%6]) with mapi id 15.20.3654.024; Tue, 15 Dec 2020 11:19:26 +0000 From: "Mirela Rabulea (OSS)" To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, shawnguo@kernel.org, robh+dt@kernel.org, p.zabel@pengutronix.de Cc: paul.kocialkowski@bootlin.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, aisheng.dong@nxp.com, daniel.baluta@nxp.com, robert.chiras@nxp.com, laurentiu.palcu@nxp.com, mark.rutland@arm.com, devicetree@vger.kernel.org, ezequiel@collabora.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, dafna.hirschfeld@collabora.com, Mirela Rabulea Subject: [PATCH v6 4/9] arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes Date: Tue, 15 Dec 2020 13:18:38 +0200 Message-Id: <20201215111843.30269-5-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> References: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> X-Originating-IP: [79.115.51.151] X-ClientProxiedBy: VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) To AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1664-134.ea.freescale.net (79.115.51.151) by VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 11:19:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6db7bd71-aae5-4ea4-7b61-08d8a0eb4893 X-MS-TrafficTypeDiagnostic: AM5PR0402MB2737: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: po22yDgm0UtT4IHO14PJuipg1hvCzD8H+um1eBIUKN6B0Vh0QMhKGkx8Y/UXCti6yEnnLvDfcb1Tc0r1dAL0ZSIa3dsB4/vUhs8oNF3YqYMOrMUeFTqbh+UeyoVKJwC3CWfB2X6/V3eo5nI/fyoMTSDxDUjHb9UuCz93OLBtvqlA8rYoAhqWp5Ypfzkh11WOSPiewGJhCqX/oNv2j3Twe333nPXrbv+FckuTAz1AJUNH3B6ySyCy52qUN2CQG6EeTZ5SUAAhrG6bvrcMq7oqy57BXh7WU4C5KzLpxZ7AmztZ/VOeaLS6voKDGGscvFYfBdJEPOfs3BcWY+r4G3Ul4NOjIIpwyoakJ5pQQaqgtruE8KXNWaRLXCwnbuxGC3RH X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR04MB3137.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6666004)(2616005)(16526019)(8936002)(52116002)(2906002)(1076003)(956004)(66946007)(6486002)(66556008)(66476007)(498600001)(6512007)(86362001)(8676002)(7416002)(6506007)(186003)(4326008)(26005)(5660300002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: KSZLd7N9hp3BCyR/ZLZn9v1k5DwwiAqy9Bh5RZxJLQI272nNfO/ROQpgHBNhSPc+lcgFFYUpF/ORkbWiS1ZLFyNKCczbBn/lxPiLMUwhV8NBHgfdyC3PmXKR4D4WG/e3yUoxrvs1y0Brt70y2nQ+OuXiOXueMGJJBw5XtqeDDFLHpwjQinNHR7JGVVYLXjGE32wke3gR2XYFChqzRTbR0JiJRS/zSGrA4k5tcJqj6HNQJ7hO7XLtYDT+wWFi4Ahbn4pK2yaUjB7G4nR27+EbpIFB1RuHEEH7eccxaSRtxJktbjf8qvqKDsq/xAS65jZqUHbcGVWbun5NTCccar251xf0uNtWRUA4fX+9XU+UxbaU0PcaKWZojWo9eAQN0/6d9whJMYS9O5B63nO6VaF0QFMBO1Wt6nj9h2rVO4QOsCF8QyJJtAGQrBPh+lIRx1eySA0xgZKg9BKfSXZ4ER87bOj6MzK67V1pCBvpMePNkcZa01bKHWCIFbhwk5+eIeOhE1/hJfnda6wo7yu9cfFPKGXfdIn5OnajSi/nxVFOHmTS7wavFBGJiMJGyypIKVtD5F8yH5v4obPuMdQKLPAr2/JXCKPd1RU0XFoX+ByOyYEzgWrNAFo2XLf6s/y5/oeqntvHxL6WOrTrZVKlDyEAnqZBb/nOF8WFF3SAVa5QPoqvyfo7aMe1gtfY8mItsmJg7HJV9ycsHiMAHA9ZAUHtsXqxjlVAbc7ZjcKv2dzz0OsB0YgjlSHvTeeE8BQeAyeY18I/ZjNrj0J7mLnmmeegxG3/ELBmjuXfwTJVz7Epqilqndja53ysunusKhWM2kh3PGGIe5mxl2djaVCh+ctvCFZcUZGPRgMW7QYPY4kPzNAZ+mM1nNtaW2JSMEngS3dfakEQLeez8IfaD9gZH4+tjps/w1aRVudErJic1ImA56jnhtdK/Rl5G3sffF4aULcQ+TCEJFy/XtKXirs56YG5MSK+O/EJMpfdbA8hLq4Vwgiq4ztIXJ2GLy8O9mV2mGmL X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3137.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 11:19:26.7499 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 6db7bd71-aae5-4ea4-7b61-08d8a0eb4893 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eo98viKMsLnkMBJtiAWTNi5PLBwtOuiltt33mJMDi/Lx0aYD7bUaWQfWvAwrCysieI/7ZZ2YMtc3q6inTpFKOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2737 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Mirela Rabulea Add jpeg decoder/encoder nodes, for now on imx8qxp only. The same should work on imx8qm, but it was not tested. Signed-off-by: Mirela Rabulea --- Changes in v6: Pure memory-to-memory are typically not enabled per-board, but just per-platform Thanks Ezequiel for feedback. arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi index e46faac1fe71..ee822560af54 100644 --- a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi @@ -629,4 +629,39 @@ }; }; }; + + img_subsys: bus@58000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x58000000 0x0 0x58000000 0x1000000>; + + jpegdec: jpegdec@58400000 { + compatible = "nxp,imx8qxp-jpgdec"; + reg = <0x58400000 0x00050000 >; + interrupts = , + , + , + ; + power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>, + <&pd IMX_SC_R_MJPEG_DEC_S0>, + <&pd IMX_SC_R_MJPEG_DEC_S1>, + <&pd IMX_SC_R_MJPEG_DEC_S2>, + <&pd IMX_SC_R_MJPEG_DEC_S3>; + }; + + jpegenc: jpegenc@58450000 { + compatible = "nxp,imx8qxp-jpgenc"; + reg = <0x58450000 0x00050000 >; + interrupts = , + , + , + ; + power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>, + <&pd IMX_SC_R_MJPEG_ENC_S0>, + <&pd IMX_SC_R_MJPEG_ENC_S1>, + <&pd IMX_SC_R_MJPEG_ENC_S2>, + <&pd IMX_SC_R_MJPEG_ENC_S3>; + }; + }; }; From patchwork Tue Dec 15 11:18:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mirela Rabulea OSS X-Patchwork-Id: 344117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A0DCC2BB48 for ; Tue, 15 Dec 2020 11:21:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADC6622255 for ; Tue, 15 Dec 2020 11:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbgLOLVY (ORCPT ); Tue, 15 Dec 2020 06:21:24 -0500 Received: from mail-eopbgr130083.outbound.protection.outlook.com ([40.107.13.83]:62016 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728806AbgLOLVS (ORCPT ); Tue, 15 Dec 2020 06:21:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C35pTI9yrg1hv2FYhut50yf2ghtYloIqY4r2Wfu+GCwUiAyzHXt+rNrzuUUBDJP/W9XCb/RDnbktQMPnkiQKvFXc7xryvg4rId8jyOkYufo4CHq/ZXJqzmn0L38IOyy0RuYGlQeSHzQicfaOwkGy6PEPrlhhXbXv33OKXFtoWK3RG5W/CiCeUzBEEfpqDdDj8WMFnypK3y1DkY1rtud1Uxi3GhhyJvS8YIJCFDYMmxN/l4A686naLk+cg6bXvKfWe3K6ORaHp0OTtbDJHm1PNAcw2+6e5cZFDGAuCZNc0tjcLln+xuM021JWE0GDO1nTBt6SImxDL7LaqKThck8iAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yMfnj/YvO+laExqG8E6E6Lt0HAvvqUQrSEG8FkOyP8M=; b=X7ohF2hH9AML+V3lWqwKeCEiqAwIBdLSw2dVOUmUyTSdxxBYXjG7VnDjvNuqGZrhbN3ghfCriS+AIPOLkRmlFLy1TZbGgsne6hJ8uhrLBytgUo8+xtSymPcT6lI+RWosPiiup7OTpQxSFQ4BMdGuTEXso28vJSkoLesJADu3JQ9a7zE4Jaut8y3rKOU3E+7/Rj0hqX29T9jK9j9XWVk3knZ6jU96DoxkCuS50RHe/88kuR1OHfnTVe5k9+a+dRbXllWFeOZwFjXFUBe06jlKWBEKqXlX3RIWrqej2XAOF2DxDuEjnErb31pMIDAb/NXI+c4/zOH/OBtOloI5k4Pt3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yMfnj/YvO+laExqG8E6E6Lt0HAvvqUQrSEG8FkOyP8M=; b=HCGl0KwGKLeI5pVvC4DsAjn+yQ519pS7CgoGvNoyeQ53wfVesg0A3ErcJiHjhq73L4mkMF+WF0L3+vnlp4JA3uuoy4dgKKQxj2ft8fuQzmFcV3R3SMAg3/KiA/s0FLrP3hdEav2n8OCFMZSElLBi+XpWp8wGV0bVqDGLoAAt3ms= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) by AM5PR0402MB2737.eurprd04.prod.outlook.com (2603:10a6:203:95::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Tue, 15 Dec 2020 11:19:36 +0000 Received: from AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9]) by AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9%6]) with mapi id 15.20.3654.024; Tue, 15 Dec 2020 11:19:36 +0000 From: "Mirela Rabulea (OSS)" To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, shawnguo@kernel.org, robh+dt@kernel.org, p.zabel@pengutronix.de Cc: paul.kocialkowski@bootlin.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, aisheng.dong@nxp.com, daniel.baluta@nxp.com, robert.chiras@nxp.com, laurentiu.palcu@nxp.com, mark.rutland@arm.com, devicetree@vger.kernel.org, ezequiel@collabora.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, dafna.hirschfeld@collabora.com, Mirela Rabulea Subject: [PATCH v6 6/9] media: Add parsing for APP14 data segment in jpeg helpers Date: Tue, 15 Dec 2020 13:18:40 +0200 Message-Id: <20201215111843.30269-7-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> References: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> X-Originating-IP: [79.115.51.151] X-ClientProxiedBy: VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) To AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1664-134.ea.freescale.net (79.115.51.151) by VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 11:19:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 926c390e-b73a-4fe3-7f17-08d8a0eb4e40 X-MS-TrafficTypeDiagnostic: AM5PR0402MB2737: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SH6x+fdV0v3R8Iga3lj28D13csxeTGQPR2Bqvguvp0ClbvgH+IbblD04W3TtvHkorc+cDSnP4aSBYAT4zHyVZAALRPu5hHj9Nz/trHMNVsee1KzEehSe+5e0N+ip30FOXb3jHXoIzYo2BeHkaOVMQ6QoOAc5BGhgGX38HKoQQVzw82WP8KtXedLqaiyRrxtEdFBI48YSKVMv4vG/p90sxgQHDuzrUwhRBdLekZ8sMpr/G28U8MMftWZcbgJHcpATsdaJ/fscuD4U9/CB02D/au0977Gvj764ImIvOPKNPburDa03CVsV9AQ2UznH+V1MwFpIhK8bgg7pP2KCnucm6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR04MB3137.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6666004)(2616005)(16526019)(8936002)(52116002)(2906002)(1076003)(956004)(66946007)(6486002)(66556008)(66476007)(498600001)(6512007)(86362001)(8676002)(7416002)(83380400001)(6506007)(186003)(4326008)(26005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8Bs1Gw8NUKuu0tS5+T8IDkguos3fuZz3+EJJ8+5uu9+6ssMml1TU6gsyfPZTkFwyZSqOBHEwqSOj/ZfwUD0WFMXhxPyqIi3cYiNy48ddSerzP0rPf7MGYfusOGEbTbxx2Rp7CjQELfpTRPzrrt1+I6Tb5cywqoyBxj8vsncnR4SsMYffI566fCQZkIlMrvSk28/aEdqRsrPYS6Pox3CST/9jvAK0Fe9BPszfowNh8ulRaExjY9VY1sK0thjPVeltwWTvNykm2QGFSdnuWi1ltw4l37ocfyihxY6KMpXCXmHeCsam1Juh4R71UvEP+ylovOj50iAWzslVknm4B5BugCJMjokBpVO1Tutg71RLZ9pczzRxO4KUTJLUwnoHiJEzneq2UKGoPc9o4VF3nYd5/kqjyicIFBrneZOxlCGjY6scdlRw6cji7Xs4nYdnMGC+Fgeb2vbeneKFEc/giqZOKcVRCkeFU3XIGnxSW8bqtBmalJP9MDXlMS0doC828wzbGY8cMS8yz04lD47l9E+xOj1HQ89pHYtuVRc/b+6eWWZkpDeYByrlzjLkZ/MJfhcriO1r8/YQYjqUtS7FhSwqlBbNbK2kfOSSEu2u2MREyV2rGfofRcaUaMA4s7/fbtrWVrm/TW2UArsrAyo5lw0YR1Tl/K/ZJlNpDtNKCdFntg+/vGdu1IQaKUy7tOL1xVUZz70NWTxOt1SFxxRsZ5UDg/xd1TmZrWoJDHkNF2JcatBk7j4/h9+NXWIcBFLeRI9YA0/95GJil/QDLxJ4p9Mj3hZMsRFoE1Pxnv0xa0CYXGZW6GbSVnf+bmCJzgjUFQQtB9ctxUCN4ZGFNV1ctv1EIp16p/fpwEi3jHD3ngNXMo54auESEshcxQByNH9mRNhkPP6rt4CYMNI9ab8de5a4fCWIJg8pGC7xniRn5R9g7kVALioTJ8tFTbAieC5UpJgkzbBPeXvE2o7MKkpgSkPNhZCBGOS7C3VcqzzkFXJ5dwsFSJHb7lopZRa+VVvpVt8w X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3137.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 11:19:36.1724 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 926c390e-b73a-4fe3-7f17-08d8a0eb4e40 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sl6Y/IsOgtPAfWlMz7rgkGKm7xl7pWppwDKLTG/UazDFt+Zncfq2th48BPnaxQY7kT5yp8qBaeTiSxL5qAPGwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2737 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Mirela Rabulea According to Rec. ITU-T T.872 (06/2012) 6.5.3 APP14 segment is for color encoding, it contains a transform flag, which may have values of 0, 1 and 2 and are interpreted as follows: 0 - CMYK for images that are encoded with four components - RGB for images that are encoded with three components 1 - An image encoded with three components using YCbCr colour encoding. 2 - An image encoded with four components using YCCK colour encoding. This is used in imx-jpeg decoder, to distinguish between YUV444 and RGB24. Signed-off-by: Mirela Rabulea Reviewed-by: Philipp Zabel --- Changes in v6: Switch variable to lowercase Lp->lp Check for "Adobe\0" in Ap1..6 Make the transform flag an enum Removed a change in comment section, a leftover from a previous version Thanks Philipp for feedback. drivers/media/v4l2-core/v4l2-jpeg.c | 43 +++++++++++++++++++++++++++-- include/media/v4l2-jpeg.h | 18 ++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-core/v4l2-jpeg.c index 8947fd95c6f1..d1483e7a775c 100644 --- a/drivers/media/v4l2-core/v4l2-jpeg.c +++ b/drivers/media/v4l2-core/v4l2-jpeg.c @@ -45,6 +45,7 @@ MODULE_LICENSE("GPL"); #define DHP 0xffde /* hierarchical progression */ #define EXP 0xffdf /* expand reference */ #define APP0 0xffe0 /* application data */ +#define APP14 0xffee /* application data for colour encoding */ #define APP15 0xffef #define JPG0 0xfff0 /* extensions */ #define JPG13 0xfffd @@ -444,8 +445,41 @@ static int jpeg_skip_segment(struct jpeg_stream *stream) return jpeg_skip(stream, len - 2); } +/* Rec. ITU-T T.872 (06/2012) 6.5.3 */ +static int jpeg_parse_app14_data(struct jpeg_stream *stream) +{ + int ret; + int lp; + int skip; + int tf; + + lp = jpeg_get_word_be(stream); + if (lp < 0) + return lp; + + /* Check for "Adobe\0" in Ap1..6 */ + if (strncmp(stream->curr, "Adobe\0", 6)) + return -EINVAL; + + /* get to Ap12 */ + ret = jpeg_skip(stream, 11); + if (ret < 0) + return -EINVAL; + + tf = jpeg_get_byte(stream); + if (tf < 0) + return tf; + + skip = lp - 2 - 11; + ret = jpeg_skip(stream, skip); + if (ret < 0) + return -EINVAL; + else + return tf; +} + /** - * jpeg_parse_header - locate marker segments and optionally parse headers + * v4l2_jpeg_parse_header - locate marker segments and optionally parse headers * @buf: address of the JPEG buffer, should start with a SOI marker * @len: length of the JPEG buffer * @out: returns marker segment positions and optionally parsed headers @@ -476,6 +510,9 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out) if (marker != SOI) return -EINVAL; + /* init value to signal if this marker is not present */ + out->app14_tf = -EINVAL; + /* loop through marker segments */ while ((marker = jpeg_next_marker(&stream)) >= 0) { switch (marker) { @@ -519,7 +556,9 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out) ret = jpeg_parse_restart_interval(&stream, &out->restart_interval); break; - + case APP14: + out->app14_tf = jpeg_parse_app14_data(&stream); + break; case SOS: ret = jpeg_reference_segment(&stream, &out->sos); if (ret < 0) diff --git a/include/media/v4l2-jpeg.h b/include/media/v4l2-jpeg.h index ddba2a56c321..c1904aa3f7cc 100644 --- a/include/media/v4l2-jpeg.h +++ b/include/media/v4l2-jpeg.h @@ -87,6 +87,22 @@ struct v4l2_jpeg_scan_header { /* Ss, Se, Ah, and Al are not used by any driver */ }; +/** + * enum v4l2_jpeg_app14_tf - APP14 transform flag + * According to Rec. ITU-T T.872 (06/2012) 6.5.3 + * APP14 segment is for color encoding, it contains a transform flag, + * which may have values of 0, 1 and 2 and are interpreted as follows: + * @V4L2_JPEG_APP14_TF_CMYK_RGB: CMYK for images encoded with four components + * RGB for images encoded with three components + * @V4L2_JPEG_APP14_TF_YCBCR: an image encoded with three components using YCbCr + * @V4L2_JPEG_APP14_TF_YCCK: an image encoded with four components using YCCK + */ +enum v4l2_jpeg_app14_tf { + V4L2_JPEG_APP14_TF_CMYK_RGB = 0, + V4L2_JPEG_APP14_TF_YCBCR = 1, + V4L2_JPEG_APP14_TF_YCCK = 2, +}; + /** * struct v4l2_jpeg_header - parsed JPEG header * @sof: pointer to frame header and size @@ -100,6 +116,7 @@ struct v4l2_jpeg_scan_header { * order, optional * @restart_interval: number of MCU per restart interval, Ri * @ecs_offset: buffer offset in bytes to the entropy coded segment + * @app14_tf: transform flag from app14 data * * When this structure is passed to v4l2_jpeg_parse_header, the optional scan, * quantization_tables, and huffman_tables pointers must be initialized to NULL @@ -119,6 +136,7 @@ struct v4l2_jpeg_header { struct v4l2_jpeg_reference *huffman_tables; u16 restart_interval; size_t ecs_offset; + enum v4l2_jpeg_app14_tf app14_tf; }; int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out); From patchwork Tue Dec 15 11:18:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mirela Rabulea OSS X-Patchwork-Id: 344116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26451C2BB48 for ; Tue, 15 Dec 2020 11:23:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D768C22255 for ; Tue, 15 Dec 2020 11:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728252AbgLOLXb (ORCPT ); Tue, 15 Dec 2020 06:23:31 -0500 Received: from mail-eopbgr130072.outbound.protection.outlook.com ([40.107.13.72]:15078 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728894AbgLOLVs (ORCPT ); Tue, 15 Dec 2020 06:21:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HGnUTN+xk8ugLiy2LbR7bX3+quL3g3hRXx9hcEA2c3NH00kGwZkb9kdCjCnZGmRb9dfeKHNx9fi3KwMFowyUIXASR3bH8fuSH/zHekjYFyD5pkap0xJ74O5XC5g7FPzbFd+lmA0tuza91IRH8muGzUJFg48juC/QgXNDjHeBLA2igr5sjxriBfqUzffuQPQ1q25QmePKKEh1f+T5rFbpLxp9mV196z3eJupnui5PuC/kJ9rN5ab/V3fRVep+Olo33VIwqUfqB5kibkHdpEi+nof4G02/9rpmIIG9WpynkcFzpD8HqtxczOsfyNv72Ykxmf596jfTiSsINHusRUs4xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O/lrVaHsvdVtyYpxM6JnfqPFiPuT5/NNGuH4ADIELsY=; b=mTaK/k+nD1TIsf5M0tTyg0KewptcWAdFY0jZOLq0zB5Lod7q3Ll1Yfbrl2qeKV0aJM79Ia3H9cwsYUFjGsVHVf7cnCjFQwMklMPCmojSTbyOXc2Vs0KGAuu1ctpTsS7q4Bpbzqy+aYtwhARLA6hX8LkkKoSrNmH7BmSvhLhobxs7ybFUkibhqR7GOKkDDy+3TMaq2vvN+5OHT4H3BJd3i8pq3AJ5Ir4ja+zKLIcv5/TmBXIEKLibDr5+on3EsJnqSx3zrzu2hoqZqEZVCyNJJ2gHHjWU1J8twiQG00Dce0QCLOV9J42K8vBrkjQ4J6cRxwEaqzvp8cSsvuQls229cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O/lrVaHsvdVtyYpxM6JnfqPFiPuT5/NNGuH4ADIELsY=; b=IvPmLbrciLfEVaNyec5knHITnGLLoQdz5aBZk/PspkWvMsb4V7Sdqa2xysKWr9eD17IjvW+w+GH4453jm1g+LQcBmJ2hBUZTqBl+OgSSS3ZbpJpjRK4hDjiqrg89m6QAo6ljNC+icbDfdba2zwbBOL1BxmsEfXe0ROgiFtPgrjQ= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) by AM5PR0402MB2737.eurprd04.prod.outlook.com (2603:10a6:203:95::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Tue, 15 Dec 2020 11:19:49 +0000 Received: from AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9]) by AM5PR04MB3137.eurprd04.prod.outlook.com ([fe80::2d75:aaf5:5aa6:5de9%6]) with mapi id 15.20.3654.024; Tue, 15 Dec 2020 11:19:48 +0000 From: "Mirela Rabulea (OSS)" To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, shawnguo@kernel.org, robh+dt@kernel.org, p.zabel@pengutronix.de Cc: paul.kocialkowski@bootlin.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, s.hauer@pengutronix.de, aisheng.dong@nxp.com, daniel.baluta@nxp.com, robert.chiras@nxp.com, laurentiu.palcu@nxp.com, mark.rutland@arm.com, devicetree@vger.kernel.org, ezequiel@collabora.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, dafna.hirschfeld@collabora.com, Mirela Rabulea Subject: [PATCH v6 9/9] media: imx-jpeg: Use v4l2 jpeg helpers in mxc-jpeg Date: Tue, 15 Dec 2020 13:18:43 +0200 Message-Id: <20201215111843.30269-10-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> References: <20201215111843.30269-1-mirela.rabulea@oss.nxp.com> X-Originating-IP: [79.115.51.151] X-ClientProxiedBy: VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) To AM5PR04MB3137.eurprd04.prod.outlook.com (2603:10a6:206:c::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1664-134.ea.freescale.net (79.115.51.151) by VI1PR09CA0178.eurprd09.prod.outlook.com (2603:10a6:800:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Tue, 15 Dec 2020 11:19:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0d701839-37a5-410f-f8b7-08d8a0eb55c3 X-MS-TrafficTypeDiagnostic: AM5PR0402MB2737: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f31ZLQ2PGdbOd4iGwxo7b1jxIDYqpD/NxNCi4mlBj11v7la4gsx4y/Y/qu0V4XApLrbL0Ef/ovpQrwBO9KQv/hKuA/TIMTQihu2DvIFt0vw4mYd5bGJb+sbHJDKDDKEsNoXqToT7blpM2BCiWphdR/BERjbB0Nxc/sgQk1V9TOrgIfzZkY6O0S6nRNM7QITvPkqPTL8UVnIavfJxj+EhUax5sakjnwM9A9oHIjV3WkjFieAbhwNL8ZoxWWFIWueBKIvfJY5Eq7zQX3N2BUnot386w9DvB2okMfsQggKNbDVLKSCSxSkCj4yZxoLJapFC3UqPlk2YuuIKCOb+Qz4EAg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR04MB3137.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6666004)(2616005)(16526019)(8936002)(52116002)(2906002)(1076003)(956004)(66946007)(6486002)(66556008)(66476007)(498600001)(6512007)(86362001)(30864003)(8676002)(7416002)(83380400001)(6506007)(186003)(4326008)(26005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: K2GVazI3JBUt9d9UNNB66YPg9uPUWM7otWkySgcf4k3lQcnBI+BHR49xyZmMJUMcnnidZCDBwu8oJLGVW23A+cKhNS2Jfvb7mCpkSyN91+vrMb+0dgzGx12W1kQARASLje7zeuIw3P+FztEBA1IznXCtiBYthrdZ1uZlJ5hiAnR5C41OH/MFrmgcmEJ6nv48funSX7glVc9pbo0aI1qTQbN2hERADmj0fx0JAjJg2BvTat4ZE2zZhzNvHjSYALqCrjSjQtdhUEvu/8mfnXwYIyQPDA9GzLg7xCY1QMP9KTcbvriLEkuRIxY7MUo7gR56eSYrpRCwbOZ4VQNtm/uW4zq+IULuctga3I7jWIrsVJGZ75tt8ZxNwgcurWyjzmI8psb777Sxk/o0nygl3Ggv7OGQLQdAFv0CfBi5YrOVAJQEFfLffZ1I3c080mKvKKaORC/p+Kbpx/hg9BOO3FLGdGbwX8JiQnObJykaJuO/pQKkL8JhAXpB7S5l3nmqNcfYLGdudpFDyu8pCSCtV+esQITUc+TdJ6mdwGtUQ226t8xqwCQJp2jj9yXlsX37tGhTZIBVriMWD2v0sz6W48tVuXd16oVapNSaz0+cTzeEW0oONI4Cxcu8uWkjtQbgrH0NtAxNZH7WWfSvHvgN84AUO/UJ3szHtNY2HoShEd6Gt/JUTBd+41LVS9mzu+g2CAL2zt9B/hCTQ79S0dOmGZssxhw7sHJS7d2yjHb3cXzSkoLJVAvUjzm/h5NjstNvwBne/fQOtDNn8AJwkaNZralwQ/gMx1uKFGug3/XdeXTWXtPmIsBmngyd063LTh8fRCFRpF17UOXR89gDiKPgObbkchisyUS9Ht+OpEWxUuHmNxQkR3+CV8PSvCBl3rVwvnQsztqxwz5G+5CnbUzeNF2XgcSyQ9seYtskIzx6W6VO3hfs9geNYFVzwWgAtNQHd5o9hgEWPvuol13B2Kn+yEaEMvb96WjuVqHWFND26xXZBQvi6jdj/yjCaqR29cDtZQnE X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3137.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2020 11:19:48.7971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 0d701839-37a5-410f-f8b7-08d8a0eb55c3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EqX5WWCgZynhHaIuMMQ4HT+f/R+6JkySoHNv6vkiIRV852oIZn0ot3ard1oi8chr1twN7HpV+0tms27np7AizA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2737 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Mirela Rabulea Use v4l2_jpeg_parse_header in mxc_jpeg_parse, remove the old parsing way, which was duplicated in other jpeg drivers. Signed-off-by: Mirela Rabulea --- Changes in v6: Use the app14 transform flag enum drivers/media/platform/imx-jpeg/Kconfig | 1 + drivers/media/platform/imx-jpeg/mxc-jpeg.c | 267 ++++++--------------- drivers/media/platform/imx-jpeg/mxc-jpeg.h | 26 +- 3 files changed, 80 insertions(+), 214 deletions(-) diff --git a/drivers/media/platform/imx-jpeg/Kconfig b/drivers/media/platform/imx-jpeg/Kconfig index 7cc89e5eff90..d875f7c88cda 100644 --- a/drivers/media/platform/imx-jpeg/Kconfig +++ b/drivers/media/platform/imx-jpeg/Kconfig @@ -4,6 +4,7 @@ config VIDEO_IMX8_JPEG depends on VIDEO_DEV && VIDEO_V4L2 select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV + select V4L2_JPEG_HELPER default m help This is a video4linux2 driver for the i.MX8 QXP/QM integrated diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index 8f297803f2c3..a33e6a071cc9 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -65,12 +66,16 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "JPEG", .fourcc = V4L2_PIX_FMT_JPEG, + .subsampling = -1, + .nc = -1, .colplanes = 1, .flags = MXC_JPEG_FMT_TYPE_ENC, }, { .name = "RGB", /*RGBRGB packed format*/ .fourcc = V4L2_PIX_FMT_RGB24, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 3, .depth = 24, .colplanes = 1, .h_align = 3, @@ -80,6 +85,8 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "ARGB", /* ARGBARGB packed format */ .fourcc = V4L2_PIX_FMT_ARGB32, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 4, .depth = 32, .colplanes = 1, .h_align = 3, @@ -89,6 +96,8 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "YUV420", /* 1st plane = Y, 2nd plane = UV */ .fourcc = V4L2_PIX_FMT_NV12, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420, + .nc = 3, .depth = 12, /* 6 bytes (4Y + UV) for 4 pixels */ .colplanes = 2, /* 1 plane Y, 1 plane UV interleaved */ .h_align = 4, @@ -98,6 +107,8 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "YUV422", /* YUYV */ .fourcc = V4L2_PIX_FMT_YUYV, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422, + .nc = 3, .depth = 16, .colplanes = 1, .h_align = 4, @@ -107,6 +118,8 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "YUV444", /* YUVYUV */ .fourcc = V4L2_PIX_FMT_YUV24, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 3, .depth = 24, .colplanes = 1, .h_align = 3, @@ -116,6 +129,8 @@ static struct mxc_jpeg_fmt mxc_formats[] = { { .name = "Gray", /* Gray (Y8/Y12) or Single Comp */ .fourcc = V4L2_PIX_FMT_GREY, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, + .nc = 1, .depth = 8, .colplanes = 1, .h_align = 3, @@ -419,33 +434,6 @@ static enum mxc_jpeg_image_format mxc_jpeg_fourcc_to_imgfmt(u32 fourcc) } } -static int mxc_jpeg_imgfmt_to_fourcc(enum mxc_jpeg_image_format imgfmt, - u32 *fourcc) -{ - switch (imgfmt) { - case MXC_JPEG_GRAY: - *fourcc = V4L2_PIX_FMT_GREY; - return 0; - case MXC_JPEG_YUV422: - *fourcc = V4L2_PIX_FMT_YUYV; - return 0; - case MXC_JPEG_YUV420: - *fourcc = V4L2_PIX_FMT_NV12; - return 0; - case MXC_JPEG_YUV444: - *fourcc = V4L2_PIX_FMT_YUV24; - return 0; - case MXC_JPEG_RGB: - *fourcc = V4L2_PIX_FMT_RGB24; - return 0; - case MXC_JPEG_ARGB: - *fourcc = V4L2_PIX_FMT_ARGB32; - return 0; - default: - return 1; - } -} - static struct mxc_jpeg_q_data *mxc_jpeg_get_q_data(struct mxc_jpeg_ctx *ctx, enum v4l2_buf_type type) { @@ -1165,45 +1153,6 @@ static void mxc_jpeg_stop_streaming(struct vb2_queue *q) release_active_buffers(q, VB2_BUF_STATE_ERROR); } -struct mxc_jpeg_stream { - u8 *addr; - u32 loc; - u32 end; -}; - -static int get_byte(struct mxc_jpeg_stream *stream) -{ - int ret; - - if (stream->loc >= stream->end) - return -1; - ret = stream->addr[stream->loc]; - stream->loc++; - return ret; -} - -static int get_sof(struct device *dev, - struct mxc_jpeg_stream *stream, - struct mxc_jpeg_sof *sof) -{ - int i; - - if (stream->loc + sizeof(struct mxc_jpeg_sof) >= stream->end) - return -1; - memcpy(sof, &stream->addr[stream->loc], sizeof(struct mxc_jpeg_sof)); - _bswap16(&sof->length); - _bswap16(&sof->height); - _bswap16(&sof->width); - dev_dbg(dev, "JPEG SOF: precision=%d\n", sof->precision); - dev_dbg(dev, "JPEG SOF: height=%d, width=%d\n", - sof->height, sof->width); - for (i = 0; i < sof->components_no; i++) { - dev_dbg(dev, "JPEG SOF: comp_id=%d, H=0x%x, V=0x%x\n", - sof->comp[i].id, sof->comp[i].v, sof->comp[i].h); - } - return 0; -} - static int mxc_jpeg_valid_comp_id(struct device *dev, struct mxc_jpeg_sof *sof, struct mxc_jpeg_sos *sos) @@ -1233,45 +1182,18 @@ static int mxc_jpeg_valid_comp_id(struct device *dev, return valid; } -static enum mxc_jpeg_image_format -mxc_jpeg_get_image_format(struct device *dev, const struct mxc_jpeg_sof *sof) +static u32 mxc_jpeg_get_image_format(struct device *dev, + const struct v4l2_jpeg_header header) { - if (sof->components_no == 1) { - dev_dbg(dev, "IMAGE_FORMAT is: MXC_JPEG_GRAY\n"); - return MXC_JPEG_GRAY; - } - if (sof->components_no == 3) { - if (sof->comp[0].h == 2 && sof->comp[0].v == 2 && - sof->comp[1].h == 1 && sof->comp[1].v == 1 && - sof->comp[2].h == 1 && sof->comp[2].v == 1){ - dev_dbg(dev, "IMAGE_FORMAT is: MXC_JPEG_YUV420\n"); - return MXC_JPEG_YUV420; - } - if (sof->comp[0].h == 2 && sof->comp[0].v == 1 && - sof->comp[1].h == 1 && sof->comp[1].v == 1 && - sof->comp[2].h == 1 && sof->comp[2].v == 1){ - dev_dbg(dev, "IMAGE_FORMAT is: MXC_JPEG_YUV422\n"); - return MXC_JPEG_YUV422; - } - if (sof->comp[0].h == 1 && sof->comp[0].v == 1 && - sof->comp[1].h == 1 && sof->comp[1].v == 1 && - sof->comp[2].h == 1 && sof->comp[2].v == 1){ - dev_dbg(dev, "IMAGE_FORMAT is: MXC_JPEG_YUV444\n"); - return MXC_JPEG_YUV444; - } - } - if (sof->components_no == 4) { - if (sof->comp[0].h == 1 && sof->comp[0].v == 1 && - sof->comp[1].h == 1 && sof->comp[1].v == 1 && - sof->comp[2].h == 1 && sof->comp[2].v == 1 && - sof->comp[3].h == 1 && sof->comp[3].v == 1){ - /* this is not tested */ - dev_dbg(dev, "IMAGE_FORMAT is: MXC_JPEG_ARGB\n"); - return MXC_JPEG_ARGB; - } - } + int i; + + for (i = 0; i < MXC_JPEG_NUM_FORMATS; i++) + if (mxc_formats[i].subsampling == header.frame.subsampling && + mxc_formats[i].nc == header.frame.num_components) + return mxc_formats[i].fourcc; + dev_err(dev, "Could not identify image format\n"); - return MXC_JPEG_INVALID; + return 0; } static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q, @@ -1325,122 +1247,69 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct device *dev = ctx->mxc_jpeg->dev; struct mxc_jpeg_q_data *q_data_out, *q_data_cap; enum v4l2_buf_type cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - struct mxc_jpeg_stream stream; - bool notfound = true; - bool app14 = false; bool src_chg = false; - u8 app14_transform = 0; - struct mxc_jpeg_sof sof, *psof = NULL; - struct mxc_jpeg_sos *psos = NULL; - int byte; - u8 *next = NULL; - enum mxc_jpeg_image_format img_fmt; u32 fourcc; + struct v4l2_jpeg_header header; + struct mxc_jpeg_sof *psof = NULL; + struct mxc_jpeg_sos *psos = NULL; + int ret; - memset(&sof, 0, sizeof(struct mxc_jpeg_sof)); - stream.addr = src_addr; - stream.end = size; - stream.loc = 0; - *dht_needed = true; + memset(&header, 0, sizeof(header)); + ret = v4l2_jpeg_parse_header((void *)src_addr, size, &header); + if (ret < 0) { + dev_err(dev, "Error parsing JPEG stream markers\n"); + return ret; + } - /* check stream starts with SOI */ - byte = get_byte(&stream); - if (byte == -1 || byte != 0xFF) - return -EINVAL; - byte = get_byte(&stream); - if (byte == -1 || byte != 0xD8) - return -EINVAL; + /* if DHT marker present, no need to inject default one */ + *dht_needed = (header.num_dht == 0); - while (notfound) { - byte = get_byte(&stream); - if (byte == -1) - return -EINVAL; - if (byte != 0xff) - continue; - do { - byte = get_byte(&stream); - } while (byte == 0xff); - if (byte == -1) - return false; - if (byte == 0) - continue; - switch (byte) { - case DHT: - /* DHT marker present, no need to inject default one */ - *dht_needed = false; - break; - case SOF2: /* Progressive DCF frame definition */ - dev_err(dev, - "Progressive JPEG not supported by hardware"); - return -EINVAL; - case SOF1: /* Extended sequential DCF frame definition */ - case SOF0: /* Baseline sequential DCF frame definition */ - if (get_sof(dev, &stream, &sof) == -1) - break; - next = stream.addr + stream.loc; - psof = (struct mxc_jpeg_sof *)next; - break; - case SOS: - next = stream.addr + stream.loc; - psos = (struct mxc_jpeg_sos *)next; - notfound = false; - break; - case APP14: - app14 = true; - /* - * Application Data Syntax is: - * 2 bytes(APPn:0xFF,0xEE), 2 bytes(Lp), Ap1...ApLp-2 - * The transform flag is in Ap12 - * stream.loc is now on APPn-0xEE byte - */ - app14_transform = *(stream.addr + stream.loc + 12 + 1); - break; - default: - notfound = true; - } - } q_data_out = mxc_jpeg_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); if (q_data_out->w == 0 && q_data_out->h == 0) { dev_warn(dev, "Invalid user resolution 0x0"); dev_warn(dev, "Keeping resolution from JPEG: %dx%d", - sof.width, sof.height); - q_data_out->w = sof.width; - q_data_out->h = sof.height; - } else if (sof.width != q_data_out->w || sof.height != q_data_out->h) { + header.frame.width, header.frame.height); + q_data_out->w = header.frame.width; + q_data_out->h = header.frame.height; + } else if (header.frame.width != q_data_out->w || + header.frame.height != q_data_out->h) { dev_err(dev, "Resolution mismatch: %dx%d (JPEG) versus %dx%d(user)", - sof.width, sof.height, q_data_out->w, q_data_out->h); + header.frame.width, header.frame.height, + q_data_out->w, q_data_out->h); return -EINVAL; } - if (sof.width % 8 != 0 || sof.height % 8 != 0) { + if (header.frame.width % 8 != 0 || header.frame.height % 8 != 0) { dev_err(dev, "JPEG width or height not multiple of 8: %dx%d\n", - sof.width, sof.height); + header.frame.width, header.frame.height); return -EINVAL; } - if (sof.width > MXC_JPEG_MAX_WIDTH || - sof.height > MXC_JPEG_MAX_HEIGHT) { + if (header.frame.width > MXC_JPEG_MAX_WIDTH || + header.frame.height > MXC_JPEG_MAX_HEIGHT) { dev_err(dev, "JPEG width or height should be <= 8192: %dx%d\n", - sof.width, sof.height); + header.frame.width, header.frame.height); return -EINVAL; } - if (sof.width < MXC_JPEG_MIN_WIDTH || - sof.height < MXC_JPEG_MIN_HEIGHT) { + if (header.frame.width < MXC_JPEG_MIN_WIDTH || + header.frame.height < MXC_JPEG_MIN_HEIGHT) { dev_err(dev, "JPEG width or height should be > 64: %dx%d\n", - sof.width, sof.height); + header.frame.width, header.frame.height); return -EINVAL; } - if (sof.components_no > MXC_JPEG_MAX_COMPONENTS) { + if (header.frame.num_components > V4L2_JPEG_MAX_COMPONENTS) { dev_err(dev, "JPEG number of components should be <=%d", - MXC_JPEG_MAX_COMPONENTS); + V4L2_JPEG_MAX_COMPONENTS); return -EINVAL; } /* check and, if necessary, patch component IDs*/ + psof = (struct mxc_jpeg_sof *)header.sof.start; + psos = (struct mxc_jpeg_sos *)header.sos.start; if (!mxc_jpeg_valid_comp_id(dev, psof, psos)) dev_warn(dev, "JPEG component ids should be 0-3 or 1-4"); - img_fmt = mxc_jpeg_get_image_format(dev, &sof); - if (img_fmt == MXC_JPEG_INVALID) + fourcc = mxc_jpeg_get_image_format(dev, header); + if (fourcc == 0) return -EINVAL; /* @@ -1448,12 +1317,11 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, * encoded with 3 components have RGB colorspace, see Recommendation * ITU-T T.872 chapter 6.5.3 APP14 marker segment for colour encoding */ - if (img_fmt == MXC_JPEG_YUV444 && app14 && app14_transform == 0) - img_fmt = MXC_JPEG_RGB; - - if (mxc_jpeg_imgfmt_to_fourcc(img_fmt, &fourcc)) { - dev_err(dev, "Fourcc not found for %d", img_fmt); - return -EINVAL; + if (fourcc == V4L2_PIX_FMT_YUV24 || fourcc == V4L2_PIX_FMT_RGB24) { + if (header.app14_tf == V4L2_JPEG_APP14_TF_CMYK_RGB) + fourcc = V4L2_PIX_FMT_RGB24; + else + fourcc = V4L2_PIX_FMT_YUV24; } /* @@ -1461,10 +1329,11 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, * detected from the jpeg output stream */ q_data_cap = mxc_jpeg_get_q_data(ctx, cap_type); - if (q_data_cap->w != sof.width || q_data_cap->h != sof.height) + if (q_data_cap->w != header.frame.width || + q_data_cap->h != header.frame.height) src_chg = true; - q_data_cap->w = sof.width; - q_data_cap->h = sof.height; + q_data_cap->w = header.frame.width; + q_data_cap->h = header.frame.height; q_data_cap->fmt = mxc_jpeg_find_format(ctx, fourcc); q_data_cap->w_adjusted = q_data_cap->w; q_data_cap->h_adjusted = q_data_cap->h; @@ -1490,7 +1359,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, (fourcc >> 24) & 0xff); /* setup bytesperline/sizeimage for capture queue */ - mxc_jpeg_bytesperline(q_data_cap, sof.precision); + mxc_jpeg_bytesperline(q_data_cap, header.frame.precision); mxc_jpeg_sizeimage(q_data_cap); /* diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.h b/drivers/media/platform/imx-jpeg/mxc-jpeg.h index ef1670dafeb4..313b09f831a4 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.h +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.h @@ -42,6 +42,8 @@ enum mxc_jpeg_mode { * struct jpeg_fmt - driver's internal color format data * @name: format description * @fourcc: fourcc code, 0 if not applicable + * @subsampling subsampling of jpeg components + * @nc: number of color components * @depth: number of bits per pixel * @colplanes: number of color planes (1 for packed formats) * @h_align: horizontal alignment order (align to 2^h_align) @@ -49,13 +51,15 @@ enum mxc_jpeg_mode { * @flags: flags describing format applicability */ struct mxc_jpeg_fmt { - char *name; - u32 fourcc; - int depth; - int colplanes; - int h_align; - int v_align; - u32 flags; + char *name; + u32 fourcc; + enum v4l2_jpeg_chroma_subsampling subsampling; + int nc; + int depth; + int colplanes; + int h_align; + int v_align; + u32 flags; }; struct mxc_jpeg_desc { @@ -117,14 +121,6 @@ struct mxc_jpeg_dev { struct device_link **pd_link; }; -/* JPEG marker identifiers */ -#define SOF0 0xC0 -#define SOF1 0xC1 -#define SOF2 0xC2 -#define SOS 0xDA -#define DHT 0xC4 -#define APP14 0xEE - /** * struct mxc_jpeg_sof_comp - JPEG Start Of Frame component fields * @id: component id