From patchwork Wed Mar 22 05:13:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 666821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE98BC761A6 for ; Wed, 22 Mar 2023 05:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjCVFN7 (ORCPT ); Wed, 22 Mar 2023 01:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjCVFNy (ORCPT ); Wed, 22 Mar 2023 01:13:54 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B14A150FBF; Tue, 21 Mar 2023 22:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HLH1XlHmRtJ7AvtFcd8bKycasMaeySw9MtLldrDh9mpsTCUFcN0gYjZWEsRDJYRw4HXES3c6TIYNHNAGwJz9HSeRgC3Zac56fD39cuUQu5ol9cAauN1yD0AWTKk3Eik0NpZ4uIVaazjl+TdmPn0xN852vbqKXjIT/5ogPSweSyPpWQtvN+0pp3ONn1ITFdUqShXrg3bcRgSujxcSf3+PlCKhsni3XZztOqmpJ+yAcNddK8NCB6M6Pj88RTzl5cUnV1jCeyCQ1A/5OGXZvJIsUe8UdtHIZPscEOdOOFSoNSMljY+l3mTYXnZqKqdkM1vIsRUg2ENL2he2/Bp9N0/+Fg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HaV1IAbypr+7qw1xD0wjbMHN8X3GD4YNlQK9XQbiICc=; b=nJ6NTuFNpixmTlhrDmZr4NYqIoQrdQY6JW0jESwfknQs65O4lNVEjAB5RU7iC19X8MlMscQJ8h9LCXbz0wzWgvzjcK+UfqZPUiIJWKeKsI01jmGvs6V2H5g4/skDTMZQ5lbdTUHgI1O5JRBgyKq/YTTJyMVStUrpNZDkjluO8+FESHCuZZueaSVpeg11rpK3po0zx8kM74OnVcdvNkyEyyX100t2smQRtc5hyV9wLZ/I0MAL1LXRa/HsWxXxXFBBl6RM6a3MfmEyHNZuRrmPrQA3/L+35frORSpAtB6nDg6MayFW+J1zPxKf8o0M/qgPtsE/NwKcmrFVscO3IGlFew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HaV1IAbypr+7qw1xD0wjbMHN8X3GD4YNlQK9XQbiICc=; b=DDMTy37nzuOp6nV5CDiJ1TgGbK8cuGvoIMtXVgBN/z6fMgPOgqN0EfTNV88zum8i6n/QGXJwSQtu9YmMiZVW5Ub7pzvMTW3IhSUT9bhTrHLKEDY8xLQBI1T+gb8oFZhk2TXKi1Jixk8pX3Er/BCFmTke7akdIwtHMekealsYFAQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8100.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 05:13:50 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b%5]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 05:13:50 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 02/10] media: Add Y012 video format Date: Wed, 22 Mar 2023 13:13:05 +0800 Message-Id: <25b44caf5b508c099f29019df23f967d41802332.1679461709.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0021.apcprd02.prod.outlook.com (2603:1096:4:1f4::14) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: b5033481-4f87-4fc9-100d-08db2a943907 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wfm5wgm9rTiR9oKuJFQMvHW4njz+OLqYOJzoO//EYEz/PYP2rlkbVKKZJADINXXhwqGOdRmydUKTzmXRS2IYZq7G467jcUY+4AnplSznTRbU2OBLI7R0hp+MyL2g6bDjSNSH1I/QylZh6eRVSmsNtj8mCU8s7WzUrJ/mlL/HpHsuCLNWho94tgVUB4YX1s42Blu7Re0MWRHJX4zE0/AIksGmWzmxV5UEDbnjD4ct0BvOC81XbU6Fqfak/ab4oka+4gScy2ClzaByk+JOc/oEAXEdhxbNkkHse4Z8xNnqpqZR2PRy1AF4sw88/Z8JJVkfxKyY//mJTd3/eiT8jK/Luf6BydpIs4unrONwLux/Cu9MbTIiiEjawK5LiDUjjR2w1qexQXpA4Vv6AMKgXMUp2zOsWQnTK5vl/Y6g5mtd6Icj1PGXftXfmifG46q0j+BCqII5t36EERgvXcgOvOgYC/9VM6xL35ZFI+h7BAEJS/eA0I0tVzOtPgO0krxbaWYpcbfbwn7shiNHLpCTDUiLYFRzOVMNBLmfn0W54rvTlIkQbA/7SUOVVZSslDFpLmmh68iFxzehWlK/qphqwAIsZbGTL06TwXj/1ZmFaD7/N9oHQB3s3phXXDGcplZevOAbZUAVbKTCUV8XqIOQ/i1VMm6tpoL+npRalDg5sHJKkIMDgaT5+NYL53iEgCdeIQswXzS1c324MIWB+xx61i/NVw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199018)(6486002)(66556008)(41300700001)(52116002)(66476007)(7416002)(478600001)(66946007)(5660300002)(8936002)(8676002)(316002)(44832011)(4326008)(36756003)(86362001)(6506007)(6512007)(186003)(26005)(6666004)(2616005)(2906002)(38350700002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QUQURGCB8353rwDa18utDtdckUQK7HGT30YBU6vONaPseuX6+b/4CVPtMz9Svqx+lMc3S7x2FkrFJt3yWO+Jcdj6LYYN0y03a/6nrBN3/cxm1fkZ04ERHrX4lEBqhFBM3LTo+sR2CZJs14LD9QQcPY1MhC21YfnGLmT2CRH8vk/dsFwzLpK/JNHdqAOqoNgVfW73+azIT0wUqbuk3MtRUQWLyh75e6wRboZnvdj759qFT5vX5pxWIZR0+pflZSNEMhOj/XTJ94BhSglQ6EbPAlCg+jXp4UrE+EBXNAam6Y+dZzGZdhjxcwLkqsDWl++Dlh1D5HqfrnF6TnUA9D+SQAYqOd3yyUJgw3Zj5ZUiCjy+LZVoF0QRXF405vOIwoAGRtHp7mxna9Qph71pu30+2IYUrALRYjCQOQNRr/f5SPX+/BMFamMhcvkTzrnuY3buvGaXT0a0T0cv+rRpVWH77YIB27XRA6Y3wWRU35JMT4l3CiNyi0qP89BCHN06gE5nOIu42CZQuZMOMsjpVYOjsJnEkd70qgHJALWp72WbxpGFKWj7AIXfJqw89d4u2rdg0E3cE4HoQW47AyN2epWiKzjmxCUJO6fzs7EzGYqRNBChaN8H8CETiDIjFSmBkHZiNreHGOl6xlVkktA/xaYgQG0PzO1kO4fz4FzfyVXZPfCXkJyWKW1Mj5xfi35q/BCsynexFAQS/lDB9q1j2v1CueSp015Wb92IsPhGRIP31HScyLbiy5k8nRWZdUe4+MrOjBev00AFtDL4ShtWbxIT1bounB5dDIuK5cUwJ9kLlh4biMvTPoxvuwKnURbMTMkpQlgCUVFdYXqWHv8WMgbgyAoh+5P0aM9AudZV15OA4+8iya0lUelhvaW6wjE6n7Jf2IfEz296OB+lqf/AIbLdtYmTQrjwOIBhkcYIQhXOo/tw2R5yOjS+4rfeI4LVNUOoxsqcjPuhAPKyB4cUxRnfVS/+rxDzuH39eb0thc5VeKUFMFXKIb7AJ/1TnRKMFrNI3WPf0Lcfb/1T9pnRjRVJqPuYJYqyI9TVo+LjIv4SKzENjBBY3yaiikXEVPdUnwdmgWQXG9xSo8/nDzEZi0S803VoF+TWF3978fBY5DG4H3y86B1bv0FcXA0slb0lri5oPbrXWo5Vfi9BS22X83cEc2GQkFUzZkF+IQe5W5B/Dl1K/qzFY4ob6MCs6GlnJBMgNxmvDdwNczU3QiiRdncZbul+UvNkxJiFz6aIzCBzb9xUqFs9mGkUw6Yesg0V7xLJ7PTY9VEVjUJvGNOU/1FbB3cNz/Aw4ieT1zLjpyK2N1gBPMp5h5cX42/iCxuwMLSN6q/v12JGjTgmjzamfW9hZwYLtwvNFwemvFwA8sHQtnyE0TVwwW/w2DmsKsnwKQ4UJ84O8Zichvs2PE6F4Py0vA9rxOw1MwRFMCUndebwoadByHKUEOsEfXXhqEc7WHEgnnYoJmW6+tmYo/0CSYrpVPdhFvROFME2Lfn3W4AlskDSnq1BZIZZYHvXC2yWbcQoXS32hNMr21OIdceNom/i59H0GkrZw3j+F6UNNmS08by5dCihfU14iMuaNdcA+dKG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5033481-4f87-4fc9-100d-08db2a943907 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2023 05:13:50.5066 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ViiDt7XNsrUKjHg5hZ+OZTHm5YSk27Q/Xez85eZjdwCNSJJ110bshR8zgDS1O0+KlpDSO7HzLDabqT7Dl83ScA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Y012 is a luma-only formats with 12-bits per pixel, expanded to 16bits. Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order. Signed-off-by: Ming Qian --- .../userspace-api/media/v4l/pixfmt-yuv-luma.rst | 15 +++++++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 3 files changed, 17 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst index 62078a01de76..cf8e4dfbfbd4 100644 --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst @@ -103,6 +103,17 @@ are often referred to as greyscale formats. - ... - ... + * .. _V4L2-PIX-FMT-Y012: + + - ``V4L2_PIX_FMT_Y012`` + - 'Y012' + + - Y'\ :sub:`0`\ [3:0] `0000` + - Y'\ :sub:`0`\ [11:4] + - ... + - ... + - ... + * .. _V4L2-PIX-FMT-Y14: - ``V4L2_PIX_FMT_Y14`` @@ -146,3 +157,7 @@ are often referred to as greyscale formats. than 16 bits. For example, 10 bits per pixel uses values in the range 0 to 1023. For the IPU3_Y10 format 25 pixels are packed into 32 bytes, which leaves the 6 most significant bits of the last byte padded with 0. + + For Y012 and Y12 formats, Y012 places its data in the 12 high bits, with + padding zeros in the 4 low bits, in contrast to the Y12 format, which has + its padding located in the most significant bits of the 16 bit word. diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 6489b67babfa..be90a9f8c94e 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1307,6 +1307,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_Y6: descr = "6-bit Greyscale"; break; case V4L2_PIX_FMT_Y10: descr = "10-bit Greyscale"; break; case V4L2_PIX_FMT_Y12: descr = "12-bit Greyscale"; break; + case V4L2_PIX_FMT_Y012: descr = "12-bit Greyscale (bits 15-4)"; break; case V4L2_PIX_FMT_Y14: descr = "14-bit Greyscale"; break; case V4L2_PIX_FMT_Y16: descr = "16-bit Greyscale"; break; case V4L2_PIX_FMT_Y16_BE: descr = "16-bit Greyscale BE"; break; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index f83a9d1210fb..db06d4c4f008 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -586,6 +586,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */ #define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */ #define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale */ +#define V4L2_PIX_FMT_Y012 v4l2_fourcc('Y', '0', '1', '2') /* 12 Greyscale */ #define V4L2_PIX_FMT_Y14 v4l2_fourcc('Y', '1', '4', ' ') /* 14 Greyscale */ #define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */ #define V4L2_PIX_FMT_Y16_BE v4l2_fourcc_be('Y', '1', '6', ' ') /* 16 Greyscale BE */ From patchwork Wed Mar 22 05:13:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 666820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D2D8C74A5B for ; Wed, 22 Mar 2023 05:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjCVFOS (ORCPT ); Wed, 22 Mar 2023 01:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjCVFOD (ORCPT ); Wed, 22 Mar 2023 01:14:03 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DFC058B6C; Tue, 21 Mar 2023 22:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIu/s3IeHAT53Rl1PiKTCVaVj0PzjSedc4dAv3vczu0MpNKXICnJJUwLsyDa7hdzzlHCdXVx1ruAGslMZ9EHQ6ZXPDRRsnVf/rj8CUa8jPn9xqgywCrm23aw51OXGo0gbMrzJN9PbUFbPgbyHiQqKwzCoKQ7jYuH1xxVxb5NmMG56Pw8720AdncehSlj9/9Ei060WuoHgpMkydamhh8gg728W34zFg+zgqS1ZnouU7f1goqc0YTyHUZYVEa48eIPHm4QcMePA0CHFhMKIt7R6Z8WI2XSoxiNnI2Rqg7MDj++1FAzQ8R8iagonvNgDlFiVrtvyBPvemONz7imy2iITw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HzTVOaUGnkWRPu5l+dlYHzF/OoH6UiLH+Wtdh1A2PIs=; b=gkEPwstOa6/l/TQeHMSTatejSsjvGBqPU8pAJ0i8+SdhTpiZNJaq40PVA6oQPAcEPQ7LG34rR6ySvUiicdRGkmER2A2cQCno4SCkEAIYSmiOjzLMGBZu4UxLTKADwrLAwKeO7hO1ZIEBNY4CbhEKq23/vvHqsmELix/TATyOq9+chu8B3g+6loMiDY2ItaqU5oNAlfJixbSEaHqs3Fkkae4T1Asag2nw3/Z2S0Ab5P/4rp3GmDfxq/rLOWJxAD9xYq77/L1REKX5pP+6MKLHAXYX6HetGH6ezVnfTVPyM0YgrlBQ21HLgR0dxkWWSHSh4owM4puR9KTOMMQwQcfXcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HzTVOaUGnkWRPu5l+dlYHzF/OoH6UiLH+Wtdh1A2PIs=; b=eW8lVyJh/D7BLwILAqWUEfVdpM9TXHnWpaLuHDTHf2W+nivi3YExg6lIg7Gl5878zvSq9dHYVWRYYN5avaBfCfxuNylRqY9ROZzwk5lyP5CW2D21gmi6BUrWpnM1/HhojnuUzfv3rkdek9UDxM+6Z7DFPF9jsC3J/1B8qOD48ao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8100.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 05:13:58 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b%5]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 05:13:58 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 04/10] media: Add YUV48_12 video format Date: Wed, 22 Mar 2023 13:13:07 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0021.apcprd02.prod.outlook.com (2603:1096:4:1f4::14) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: f1944c1b-02c0-4e52-7b45-08db2a943d92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gC1Thh5GWrTbGohA8CAYUQAyacXSdqPzAUgq7i+aeTjLt9VPI0BDpsqQr6SrHAKLoHuZHewkWYz26cXZ5uP9jXX10Gm77UT+SjMPvtBmNRPm+aDIg0wuBOXNz7WsK7mSBKr7FGPUsRcU6bIbvqqkaMcq7yt7Osbge17OqHFkahTAotUKi62sGUOEMXdEoIbmgUvFaYgSBCRyBnOY3UWC82oQ9xjTbzimrUvb3ufHTDn/TPW4Ozb0u3HBuz48q8f3Y6Nwpcfrx+1jHde6Gz2dF41BXczDuIlfu+iHWDIH0u9c6PCel6fB+aV0/trnbLXsQvFZM42TWFS12fq6hJQ7Ig7YtvANujaIlEA9LMC5B6dVP8H0eQk2Fky0rRVeV2dRxsOSNiX8uIb6nKqjG9z35cIOEj17VUDzjkm/P+qac1kJ2Laezkvq5VJgkaH5KTJ2ozdscnUemJ1ms5Nw/oe1speUtNF3kgH6sUHEURVXBwiPMhU4iA4BBABEOk1TjNrc9TENx26KcmiVxgkTlUkBNQ7YpfLwegUDIyZ/yWbY59uE0w6J/Rr+CN8IsnHWzLiKcDm35A8tiJ6p0UC/hkEHT12ID8vsVDJR5U2DxoxOqFFy7gKe+COYvRa7Dd4KB7FmA4p8zYEFNATcYkzZzVi4QFG7MDOKhdD41HvCopJPVFZbxeoaWXhugX//VXJtbppMsskXqvCoiasd11J+VFVC+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199018)(6486002)(66556008)(41300700001)(52116002)(66476007)(7416002)(478600001)(66946007)(5660300002)(8936002)(8676002)(316002)(44832011)(4326008)(36756003)(86362001)(6506007)(6512007)(186003)(26005)(6666004)(2616005)(2906002)(38350700002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 96sCNbxC+MaIz/vv/hUeMwhCWi1AeuiFXh59MFpCGIqe9ALaAKLp9IxPWwwNha54LaztHZn4aG6oRBQEZr6Bf8PVqf4LOfl1r9KPsCQ4Qnqdjvru3t8LU629u5GS6X1vydz4agP542qClKni9Rcp/uZ0DEkaQ11QPpudWnrC+f7rXkIVMIWBb1A5Mmo+byuk56hBfgjcQap1yhGIg/xatTy6xwCKcFr0B74hVpE2OEDVZXguC+Zqn7oE3qTglBhAdjMFrs+YITwLo70IHZe+kGBHf9TofvNnwJVqna0y5HKeVtXCNYBEagMwAr9xbJceSg3/L2JYfLfNIN9vPkSNDCMJZ7vuvN27CJWcUOF2ni6EIoVX9E+tGDZRkk5Vfe86DMPsfuLpmviKY5wFrM2/0jRRI+ZBQiDuOoHaoKVcQ7HW+7DIsPhgNutoudBcfpqAdkvOrBRKKIUQBjh8A7A8BQo0mmV1yy+IYei+X81FBkE/8LhE+4bZv+8Z2dHv4JExSauktubxfDM33RAsCDQtMXq401uJS1DMLWX8tqW+y38Ruu05HQaUKfm/c3AkoYggOuc+G5oZkU/504o2IrEACD8o+UuPlhAiCOxaeZYFj/lI43zMDE48u72jFRehPVH9lz2p6fjY5J2YxsZKqrWlcw7BW5BaCz0mjbTDc9a/FgU5sqDLVeF5qFYc5GMb6QVX60SeSJtt6u0Add+rEotb8qP79AycKy0fyphJit+ddJMQn5RUmTiB06+jzXxHKzHd/cRth2wmvCHLTNqMkm68FX76dgQGT0EcMJVAKQPgjfubyfaajw9YWchVFUbhk23++cIwvnuyg7opVhlSjxTX9p3pZnYVVxRwtdaP2PIJ0EI2AlrbFAFEoMG14MUDq9Xh9PXjoQSrwZ2cIE9oG9lgIEjU1J0schzzPA44gRUGJQwkMdXHY97EPgUtPvwpkgPJ8VgT1QotMBtfPEV8HkIFrY9GAwN3uwsenBDWceXCZ8RYS0fQhD71eq/EO5Ph0nw6aWzzM/i8xIutElry8q6AuqvXe4SvJl7hrLS9gPrUXiewORZ0FcUrxgXi2wWzQaWCzYSdVS4XsDtqsLWQF26OdPgDQwlz6k5SA79OXtLuIFY17+YOfEABpEoJrZDzlGI76M/ZzlxwWR1ceYjP4ZBN7z3InvgCwIPEj8G57XowmI+U/sLwuekRM4lBx0STJP0n6JczCJkXLkBFo5tzL6UIh8+oaNR7XQMa/Gi4Ded9vhqm7dyB8+G7c+sZBk1qtmgcwyMStkyh4jA+sM5uUdVGKmqYX9Ega8xyPkoV3G84kG50vdwYpyvN77el8IzB08s+xDWMWE6x5ubviPDsY1uCojIM+OBOzwH8pBPmO2jCIS52YfWCZGE3NFGeuXJWU9E/kVJG8gGGuM7Q3RlX0bR0cKiamQ0QGU6ijNbJ88AhnO3XVmRb4sBWzHoc/dYXoSkoIYmWhI3MMg42fQedZfzno9lRcNuKDCj6zf0Z30s8s1jfU+Xf+k0fEqCbwGAWdIGFy5dKWflAOsd3FeGZmON74ik2o5mt6zvf/RNrpRaSnDaqmxqE6A7MBB+e8DkMjZfV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1944c1b-02c0-4e52-7b45-08db2a943d92 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2023 05:13:58.1312 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fpEOMXgCVKkeC7AOfU/RoX1ALYp0K67njINoeQulp0bj8KQqj/qEr+ZxvLIDH1BfY7LDtfV1de1FRs4812ilnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org YUV48_12 is a YUV format with 12-bits per component like YUV24, expanded to 16bits. Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order. Signed-off-by: Ming Qian --- .../media/v4l/pixfmt-packed-yuv.rst | 28 +++++++++++++++++++ drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 4 files changed, 31 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst index 24a771542059..fd6642f875a8 100644 --- a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst +++ b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst @@ -257,6 +257,34 @@ the second byte and Y'\ :sub:`7-0` in the third byte. - The padding bits contain undefined values that must be ignored by all applications and drivers. +The next table lists the packed YUV 4:4:4 formats with 12 bits per component. +Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits, +arranged in little endian order. storing 1 pixel in 6 bytes. + +.. flat-table:: Packed YUV 4:4:4 Image Formats (12bpc) + :header-rows: 1 + :stub-columns: 0 + + * - Identifier + - Code + - Byte 1-0 + - Byte 3-2 + - Byte 5-4 + - Byte 7-6 + - Byte 9-8 + - Byte 11-10 + + * .. _V4L2-PIX-FMT-YUV48-12: + + - ``V4L2_PIX_FMT_YUV48_12`` + - 'Y312' + + - Y'\ :sub:`0` + - Cb\ :sub:`0` + - Cr\ :sub:`0` + - Y'\ :sub:`1` + - Cb\ :sub:`1` + - Cr\ :sub:`1` 4:2:2 Subsampling ================= diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 21ace56fac04..da313a0637de 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -259,6 +259,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_UYVY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_VYUY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_Y212, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_YUV48_12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 6, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, /* YUV planar formats */ { .format = V4L2_PIX_FMT_NV12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 }, diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index be90a9f8c94e..7225e566c528 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1346,6 +1346,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_YUV420: descr = "Planar YUV 4:2:0"; break; case V4L2_PIX_FMT_HI240: descr = "8-bit Dithered RGB (BTTV)"; break; case V4L2_PIX_FMT_M420: descr = "YUV 4:2:0 (M420)"; break; + case V4L2_PIX_FMT_YUV48_12: descr = "12-bit YUV 4:4:4 Packed"; break; case V4L2_PIX_FMT_NV12: descr = "Y/UV 4:2:0"; break; case V4L2_PIX_FMT_NV21: descr = "Y/VU 4:2:0"; break; case V4L2_PIX_FMT_NV16: descr = "Y/UV 4:2:2"; break; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index db06d4c4f008..8a6430bc4a00 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -621,6 +621,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */ #define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */ #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ +#define V4L2_PIX_FMT_YUV48_12 v4l2_fourcc('Y', '3', '1', '2') /* 48 YUV 4:4:4 12-bit per component */ /* * YCbCr packed format. For each Y2xx format, xx bits of valid data occupy the MSBs From patchwork Wed Mar 22 05:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 666819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45587C74A5B for ; Wed, 22 Mar 2023 05:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbjCVFOv (ORCPT ); Wed, 22 Mar 2023 01:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjCVFOl (ORCPT ); Wed, 22 Mar 2023 01:14:41 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27D250FA7; Tue, 21 Mar 2023 22:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=no4A0juhGJPAqO+Ds7UdKv72uYmEKNnu34ba0yPwPPmMKL4TEfy0fcF2ifoxVRssC2tbgc/5tgto/Xj1hKP5SxBu+otPQ3MtEAS+44TERDLUf3NtRztXSPaYfs2VR7sIzeqyGjGXxNnPplUJrIPnQYVrSLDKCKHWXi8Ru5T9cXX8WkclVXjztjtCXTas5d3IgPwpRX22A/f+I2E54VnWoMnBcvhqtsxyslxDaE/1spOnuftRkUCSHrg4ORbZlB9zSB8skfJZqfM6NOxxGjIxplBmpMPh7K4iDVIYkWD1TrRuR2va+I645cMonowWTRk5RcuJ2rbbDBff0yz+YDc58g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bg8E3rFasrAzSgljKXK1Qi0OQIn5iLNLHNqDHkzmrgs=; b=kcQiJVW1TG7rdUXu7OSlgXD96WcEKRPNezwC7ovdoPQJvI7kekmW2xcjrWgPYs9+wFcQ4LlWlSAccHriY0xTIi8zIovXfyJ/SBcdraDD3A53TcURojyYGG31GwqCn+OdRu3gh8ndf2UMiLlaLDFr9bIGKJcFXSs9c8WlJXlSYNrEY65PsliFXJZuHlTvNtof1fZuYEjFaxcptsTzrR3hOi2FzTg/QzoOlsijI4v2dcHq5es1DHDphtvXOCA2yFb3G+5K6F+Ygl+mwgJJ6E0+38QpoaRMMZ7dO0agJDsxKchPg5+f+59hmGOecpqm6ejZDYRPcbCCR1cJYwsKgfFfRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bg8E3rFasrAzSgljKXK1Qi0OQIn5iLNLHNqDHkzmrgs=; b=rh/4CrsiEAC64VbIJfiwwljkqBCrAHfLVcS3M269vwCQPGfOicS8Il7+9InH8O0+w2PexsN0H46SNWj/PFoGPdoMfZCtFEXttoMCUJjRAaEtOanSgvhXqz1rlbQz+3PHJpkR8zBGgdNYHJlqJmaiGE1uHc3ncfmeK2TPCV4qUTk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8100.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 05:14:05 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b%5]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 05:14:05 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 06/10] media: Add ABGR64_12 video format Date: Wed, 22 Mar 2023 13:13:09 +0800 Message-Id: <9c250d2e65405d920d2918521cc86f47c7e78ec3.1679461710.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0021.apcprd02.prod.outlook.com (2603:1096:4:1f4::14) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: 960ff9f4-c4e4-4a57-48b9-08db2a944220 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gi72wmAD8VEeZzyjn8XJJ+iXJUVe5+d6rGO+9R0TwB3epqhyqN6EtVgpaizdwoiTLLBcu9n3xmBqBLpl5/5PJ6tu1E3FybOjMqhjVIrbVBk4lyvz54UeIfuruUJuzFI7lipSeOfwHij0SEM/GPk5AV4+wHz/Qyl85bsoMicYXJLFwUYBTHVb4OK1+eNInV5Bz9f+B/xSfXOIOW74NPqbVx2J2WRxwkhch4wg3DcftwCRCqXbvi1xW/DlMXrGukdoZPcBeUPsaCTBNSXGdl8motkYjfycjZgebx9sC5szs0HfGFcvQRpS7gh05NN67wsxf8Qb9b5szsOdUelsvm9IMvVJXg/ZoNHUnpxqy1Fsk+BkVuId/LvWhuhRR1AmZ+hiZWWmfqw4hn6Ir16Ljl2JI4o7fpiUkp64CRlddK6vri/zEHxT1RmfWwRk6OhVrLLK6h9Mmv1K1kJszStxLfgn46uYVYbfbBbwzf8sKMm5e7tR83z5V/ThftOkFPmUOlFiU1UfE804j9lCm3U5cnBBL69k4on8hLOTBdlTdl92RpeouYM+0DOcK9bmfnVJRrwpJrt3uJe3mtPKkCCe5frKd+pR3H3JHcXeurP5TAyAM1cGa17by9CkQYu5oofGSbevNFL/0IIMuUhIrDYIXXdD3mrPRIAmBcnW8rEyJc4HnCGup/rZqopVbO/j8GbhHVpCWAZk8QsKBfpb4TTNyiQPFA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199018)(6486002)(66556008)(41300700001)(52116002)(66476007)(7416002)(478600001)(66946007)(5660300002)(8936002)(8676002)(316002)(44832011)(4326008)(36756003)(86362001)(6506007)(6512007)(186003)(26005)(2616005)(2906002)(38350700002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UCBugjvHGnVM2+eNSF7NR5y/3ap/1EGsROTTbAx3yFj+adAgeXAuIBSANs2wpvwuyl+gZYFypiW4ejyJxOwGAcgMiSPD63F45tHiLCKzWEL38iAY+Qo1SfkD6BOMPA2a0xyLW6df2SqpbCedRE21tJkcKVtW1fSozGOLrn6u64eUuRQ3PUU8Gfa6jRZKj0HBlKn7W89JKE/wARLu980WrIfwax300PPESBu28JO5n7RpCBM5zUa2QKyqO6NBVH2l9RXKysBDWNFzxwc8epkq/LWW3wAPtF3Advnp/x/cPgkRwTJ+PgMS4ETC7bIv8kRoW8of3ksZPHzMSwmLxmjuERwT1MuBCI4auDVmuBerCCwuf04xFeqIm8zBz9NbPcG+92Y1qYq3zTOx6SwmQ0WBX/uaTkMiyrQOBlLgvn29fUz8y+tlqRaGojO/YF3VKrbSR1FINyhTrDa9E25WIp4a+l6KyPAcJsB73FFEvIGmLyuUCz7RpzMNEpoRXIwFZ5U1rUKPOw2O4lRUHLVOmZ3Smjlld1EhYsyf616fm+bHcMzEOaPETX+sJZUj1RbdJ/UxVIEOHIGsjyz7BFXm/4vJOYHBMa2PkPoSZeLcEPqQsoMQZ6MFNF/VHk7G+ctNvMuhIGhNaTogjZ5RPRvEXT9X5dAHZSqjy+uThj7JXzYdwXZGhjrO9QqvFrCPaYMVRaIFqHi3akGSL6xBrH+uollKoaQWHyKSB/riOCMRl41T75SaE4YsHtUa3S+K7oiDQBf/bhrHUvD5jih3ko6e9fiFM81JLcykDc0afFqs/2O2T33wpFEgn/Rxi+P6jureOAeRfFgBMlGms630PWexZLfGGcrlgEF0ZqH3gYn3hcN6p7mgV3Ru/yy62JMc5TRZcjifoFI+sMX82WUdr3F4ZI+D2IrJvLTmh9Y5aibJSd3QKZWGMCA2vmBF6w1spHagWTbWa1YL429T9wmszO1ti+/BaJCgtkuaS7+jXzFgkeOjboG+f9oxnJmtT7grKCEojiEP3VJRF7xnXnlAVJyyEMhdR6ALQmspMqnP9pkqKDOmhu0L+gpz2OZwl5zuzZxXeW9qJLCAZByAJ7F1WR41z32HRrXr+CVFSzpk0o16EeylAyGebWKxVvg9r8VnMh/U2Phe33+WXoBG7Ek7NEpu90+uUSgtTpNl6Sil/I+AgTg7G7QtOJROgwkqsF68l+rpMWxAS1w3o+yDhxNM0BrLJRNqlETtNE0EcrEMZh6gMVQS2ThNmBk2zVnP6Ais6RuLd1gE1uoW70+ZGXIXZAsdupefFtj/nSh6zEKzym/JYUVuJb7L+MToE7G5R958+LNQ+2vEwr0TZrXsG27XgSQHOS8Pg3FQbfjVuwv94cYomzmtfu8aYGW07npjmKnPOlfdzDRKUZ3ti1hualVG5zXTF1hiABrvXB9yw07lsGBbPoprZHSGdX8XaA7tB8ms597IbzG8Pb6Zf7P/luaNBRs369PhkjUBTDNpCF67emeRB2eChsmBvLM6O/FtxRQY+B1L6i8mAho1iPfXSvP8dIsBIUZMv8oQ107HXNNvB7lkCmu9JiDF9bQIOn5OdWB5x3JUQrdT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 960ff9f4-c4e4-4a57-48b9-08db2a944220 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2023 05:14:05.7714 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5tNJp0zxgySRtbZrPQT9LOpbLF2uUA2HZSjNy13wfsFtRtKOP+M49ktHgyDddrNeU1u9XS3+PYcZVT2TxXSRtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org ABGR64_12 is a reversed RGB format with alpha channel last, 12 bits per component like ABGR32, expanded to 16bits. Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order. Signed-off-by: Ming Qian --- Documentation/userspace-api/media/v4l/pixfmt-rgb.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 4 files changed, 12 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst index 779f0bdda642..38811025d71b 100644 --- a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst +++ b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst @@ -985,6 +985,15 @@ arranged in little endian order. - G\ :sub:`15-4` - R\ :sub:`15-4` - + * .. _V4L2-PIX-FMT-ABGR64-12: + + - ``V4L2_PIX_FMT_ABGR64_12`` + - 'B412' + + - B\ :sub:`15-4` + - G\ :sub:`15-4` + - R\ :sub:`15-4` + - A\ :sub:`15-4` .. raw:: latex diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 16d3c91c7da2..3c5ab5ecd678 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -253,6 +253,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_RGB555, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_BGR666, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_BGR48_12, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 6, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_ABGR64_12, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, /* YUV packed formats */ { .format = V4L2_PIX_FMT_YUYV, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 }, diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 3490eb3f42e4..b87c7d24d3bf 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1303,6 +1303,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_RGBA1010102: descr = "32-bit RGBA 10-10-10-2"; break; case V4L2_PIX_FMT_ARGB2101010: descr = "32-bit ARGB 2-10-10-10"; break; case V4L2_PIX_FMT_BGR48_12: descr = "12-bit Depth BGR"; break; + case V4L2_PIX_FMT_ABGR64_12: descr = "12-bit Depth BGRA"; break; case V4L2_PIX_FMT_GREY: descr = "8-bit Greyscale"; break; case V4L2_PIX_FMT_Y4: descr = "4-bit Greyscale"; break; case V4L2_PIX_FMT_Y6: descr = "6-bit Greyscale"; break; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 3c5acd72606c..a6df69ce5cf7 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -582,6 +582,7 @@ struct v4l2_pix_format { /* RGB formats (6 or 8 bytes per pixel) */ #define V4L2_PIX_FMT_BGR48_12 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */ +#define V4L2_PIX_FMT_ABGR64_12 v4l2_fourcc('B', '4', '1', '2') /* 64 BGRA 12-bit per component */ /* Grey formats */ #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ From patchwork Wed Mar 22 05:13:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 666818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4919C74A5B for ; Wed, 22 Mar 2023 05:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjCVFP4 (ORCPT ); Wed, 22 Mar 2023 01:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjCVFPy (ORCPT ); Wed, 22 Mar 2023 01:15:54 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075F058B6B; Tue, 21 Mar 2023 22:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReheG9/pa3wub4vfJr2rOPyxgMqLgx+1wzCDJ31BO98ry+AfjSZMaIwtUzu+r9IAdO/DZS1y/oGL70BHgTvB3kP29+8mjbF3QkEyJMm8IqQzEqAdSXDVSwe6KtQesihpCRAaaqICPyE3ZMJsHsNTiHMSoYjj3ZQBetknphHqTadPbpccDgTTqRtOIPRUOoc/S6oJPx37WzOKOnyug2uxyDVistAgoJE3ztxEmwiV1JfAXZFdNNzgUDSxFnBR0lNLlwFEBu9Ui98hxPr7kVGaG/8EjFmwe1/UNEMKlwZdhdBqP8h8hAe0raH2nKlxKnWsm26jhDzl97TweIVeDqjwUw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4KQHy4ojmtQF1BduRAXSRUeX6FHJREEZUO4mQRp9hxA=; b=kxXFjM+RuiR4ZZHBj0+RVTg7vDCJIfzojPZ1FvoXkyeRNAQZyyhu0LnhH5fLDGpADXAbhv9vKTy2NQk7A9h4IONV8FkeWxuuFWpNCppYqVpav/JiPFiNNzD1Co3fiBGponKX9GbkbSHaiU/WJcpBA/4r3KtsuTO+X9iPY+t5O1u62aqcToa7c4U9HXvT6g8dLXuqxez6+Nv6zLRF61zMThbB7KdpBFKmSzBsHVz8/xUqxzBW1PzXWZShg1SNUm0naTolrNFWVbXQbkP+cZGa07kO3lG4xOx3x3K0O6cpr8lPM6brjEUmKWXjiSf5iVBUd2+wd4ojsdtTrs/rqVgBTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4KQHy4ojmtQF1BduRAXSRUeX6FHJREEZUO4mQRp9hxA=; b=GhO+2GOT8byskifRPPqRkCs9Pa1dBIcPwvWAwN2feGCHtjZIloIALkRdDIxFs+Q78ypwnjUsedMddCRIlPDuapdnMe76klRnSD7gLkEt+M/wq0T4MSL1NKDngdVhzw/YSj5JJm8MWnscY5z0OeaInqmB0gBVDB3JbYjJkDriFh8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8100.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 05:14:17 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b%5]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 05:14:17 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/10] media: imx-jpeg: Decoder add support for 12bit jpeg Date: Wed, 22 Mar 2023 13:13:12 +0800 Message-Id: <9bfff536b5a7f952faee311cf689a1f5b79a47ef.1679461710.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0021.apcprd02.prod.outlook.com (2603:1096:4:1f4::14) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: dcadd56a-9b33-4343-7c0d-08db2a944904 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2sOTBGc+veMuD7Cidpq/HSsj520/AG668l8bzbKshawL693zcSkTGbcQf90ycC10mwGg4az+IOaSWiz2+KyLy8l1NdbCYfY0POhoBeMm2KSxWIPbOsjaI/dOh37CyqgE1zrD9KXA23SI/X0BDIorZwfyYksW31a5dO9G9RzFTNEIdebOzn1VEL0cyA4HIFMUsgHv6MsHEYTlz8JUgTUIwvYoxTgNMd2r1UpSw/zqWgJjHqDfqf32QMmMp6TKblv3rmyK8B17PpAIrPDr9fGaLoDh12NTJ6BjyZHH+BK11hSdJ+QWI/G5mmdf6LOhAanRjC99FOgVu4PB7w/od+pVCZqBWz5YmYwWypscmO3ezN+/yPPGnvvjMRcHD+SYCJnJEv5XDQcsbl9AxBzeDUb3veMVXOI/jmqD+I2GSUH0Ik/N132x/BjvqWXz/t5R1ApTSmy59yqN4SQPoVGDx5U2Y9AGZzGiR82VpCyFgbL0dXEPAcwMGt8iML+/Cd7uPVKIaSrf/aaTi0JUAOkOwXTFYb5rxFl4S2l2o8Mf+G/gpq4FxSlGlZ1fRt4sHjrtRvQYWJfD3W4ekWZP6d6Wer5t+bRNOO1gmGjTDN9gAZ592n5yOUnGIaOUN6XXgNu3NVpXVBHdLKFS5uEiJqEmQ/PYctnsngeH9X51i3UQucY9gsM3qAXBQODNsRu6cXhKAg2MOOrL2bhJKeReC8qwFjEy5w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199018)(6486002)(66556008)(41300700001)(52116002)(66476007)(7416002)(478600001)(66946007)(5660300002)(8936002)(8676002)(316002)(44832011)(4326008)(36756003)(86362001)(6506007)(6512007)(186003)(26005)(6666004)(2616005)(2906002)(38350700002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZOa4Z0XDm75Rscb4sjJfQYOyYyHDaoMgKLSLo+2MWro8u5KPN+XNS7Ga/Cd5n4vmwzQaa3Fk2tYuNHW9xc9qyBlJk+cz4Kp8etmD3lcTab+IRP8NjY4Suk+BE70c4JFq0yj99lQE0tNSzZ6hswPeMJQ893WMUm/nZ3Y0sClYWf98Jcwd9SzCvuoxVXUndHkqmM/xfoujdYEMgUHY/TwKVIMuo2sgSVh1JTc0gUyIkKuUcAIe6ngcimqFg6qTkK2DvrlKFXKSe68MnWiPQ3h0pNYNakYCz3SD1h2f6n2aImLlTIbSMxgjtUM1H1M2oTEpz+wdiUq0z0uWIA6Lj3PWhYefaf1KfqYnPjJD2WVmXozvOTzCtBf2VlOyWZKGMtq0CN6iPq6mgdhfNFfZmWSHGnAEwmQwdA+BECd7GzOBLQP+ztoMJdXWQef/rOl632ijKJBgYki6MvW1ESyH6ousWZo/0pFXEyzsvGak4iaENGmqt0C/m6NOTScLklqZy9hxY70FK6YXHtrfxbzg1kDloH5WWHA9mpjm5LRiftTCVRAnvmJUczzPJnv/a0Yyo4s4dVPYA9WQmYjuq92meW/GCUFtX2O/zOdtaXpQUzUUpAguoJz5xjjW2owOI20nJ5dP8dnOix5KfrRTH1DEluptiGT1BS2GeWQT8jbrtqQsPNBV38cSHduUaJhz5uVxMYB5mKxgJerD3TgETtDC/CC+C+nx57QoC+TP7ZB3D2nF/zpbvbNlgu/0HI7O7It6QsHMbcfvfIKexTe4qZzmwMwEOwX53NnGUrIsG3V96eUkGOEz9VnFx9uNoaj4mAq60G8oqpb4pF5HCcRxzEODiHF3P9gP3eRnuqnHEiAL2pjSufO5hEm05rQpJcj88tt1bV6vnAFq+9CmRapQhzp1C5ogR7D1HbnFtlVU0adVKce1J9iaS4n/mbFNqIWg56BoDlmX5di1Dhl2HslcCjxMFDlRkbxDu39p2iqfsRjK74Fn1awwTTN946qeBFBnB03hzkV31xRcdLQgrfAzrAFlBbzsdcLhTzHlAhRtz82XRCWsYNJjXh2lLXLpFwhNqj4QdOQLPWpRgx1CnTAZkh6kf8Xf9ptyq5USNZ0T/+PcqQigGOIrhcggqZw1Ds3lwdDflMN+gw28DOLDbTeqoyxZ0BTpZO7ZFxvJj8rriXgv493xCjlbGwMJAuzaFSrwmYRWRtm2s386NOvAgkS7zkG8h1We+OHZA+sX/E41uDEGfF+DDIrURqzU1Kz7hy/I+eXjGhKtyg4EKtaxb5D6snTZ2WZxnx18j+kLpG67bbrw1fBImb2Z/Tpy63XvVxF8iX0ROn8g4atJt+C2ygUMiHEGlueW7tysfKi+l25hkx6yNkf00O4vKKR45ibvHiQPDyCJzjfCrUswqCOaCoivLhsK+2Bk1a/MQ3VWhU/rdo7Yijuf0jDvdAy9kXcLWoTPO6c92POWBLH9Q/qgoKRAqHrig2uIVQprOW+8RwBpDVBhPZ6EyT+T7qjEb1Bok234dSX0KBOF9IfAVHIVThpCf1V+gGtOMsyWw6Y8Zet8OFd35DLTnEqzsdPQ9ZwgylmnXjbq5Lzw X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dcadd56a-9b33-4343-7c0d-08db2a944904 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2023 05:14:17.3489 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0wZGwwxXPdndx3wmS2dhfg+eujvCGTM1ByIA+wdizqYKj+aw/Cs+fyFPVXh3jdgegnOY7dEIlWQ/CKDKFDzhtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org enable decoding 12-bit extended jpeg Signed-off-by: Ming Qian --- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 136 +++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index 3f1c9bc4b144..74ecc5415aa6 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -87,6 +87,20 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .precision = 8, .is_rgb = 1, }, + { + .name = "BGR 12bit", /*12-bit BGR packed format*/ + .fourcc = V4L2_PIX_FMT_BGR48_12, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 3, + .depth = 36, + .mem_planes = 1, + .comp_planes = 1, + .h_align = 3, + .v_align = 3, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + .is_rgb = 1, + }, { .name = "ABGR", /* ABGR packed format */ .fourcc = V4L2_PIX_FMT_ABGR32, @@ -101,6 +115,20 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .precision = 8, .is_rgb = 1, }, + { + .name = "ABGR 12bit", /* 12-bit ABGR packed format */ + .fourcc = V4L2_PIX_FMT_ABGR64_12, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 4, + .depth = 48, + .mem_planes = 1, + .comp_planes = 1, + .h_align = 3, + .v_align = 3, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + .is_rgb = 1, + }, { .name = "YUV420", /* 1st plane = Y, 2nd plane = UV */ .fourcc = V4L2_PIX_FMT_NV12M, @@ -127,6 +155,32 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .flags = MXC_JPEG_FMT_TYPE_RAW, .precision = 8, }, + { + .name = "YUV420 12bit", /* 1st plane = Y, 2nd plane = UV */ + .fourcc = V4L2_PIX_FMT_P012M, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420, + .nc = 3, + .depth = 18, /* 6 x 12 bits (4Y + UV) for 4 pixels */ + .mem_planes = 2, + .comp_planes = 2, /* 1 plane Y, 1 plane UV interleaved */ + .h_align = 4, + .v_align = 4, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + }, + { + .name = "YUV420 12bit", /* 1st plane = Y, 2nd plane = UV */ + .fourcc = V4L2_PIX_FMT_P012, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420, + .nc = 3, + .depth = 18, /* 6 x 12 bits (4Y + UV) for 4 pixels */ + .mem_planes = 1, + .comp_planes = 2, /* 1 plane Y, 1 plane UV interleaved */ + .h_align = 4, + .v_align = 4, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + }, { .name = "YUV422", /* YUYV */ .fourcc = V4L2_PIX_FMT_YUYV, @@ -140,6 +194,19 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .flags = MXC_JPEG_FMT_TYPE_RAW, .precision = 8, }, + { + .name = "YUV422 12bit", /* YUYV */ + .fourcc = V4L2_PIX_FMT_Y212, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422, + .nc = 3, + .depth = 24, + .mem_planes = 1, + .comp_planes = 1, + .h_align = 4, + .v_align = 3, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + }, { .name = "YUV444", /* YUVYUV */ .fourcc = V4L2_PIX_FMT_YUV24, @@ -153,6 +220,19 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .flags = MXC_JPEG_FMT_TYPE_RAW, .precision = 8, }, + { + .name = "YUV444 12bit", /* YUVYUV */ + .fourcc = V4L2_PIX_FMT_YUV48_12, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444, + .nc = 3, + .depth = 36, + .mem_planes = 1, + .comp_planes = 1, + .h_align = 3, + .v_align = 3, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + }, { .name = "Gray", /* Gray (Y8/Y12) or Single Comp */ .fourcc = V4L2_PIX_FMT_GREY, @@ -166,6 +246,19 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .flags = MXC_JPEG_FMT_TYPE_RAW, .precision = 8, }, + { + .name = "Gray 12bit", /* Gray (Y8/Y12) or Single Comp */ + .fourcc = V4L2_PIX_FMT_Y012, + .subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, + .nc = 1, + .depth = 12, + .mem_planes = 1, + .comp_planes = 1, + .h_align = 3, + .v_align = 3, + .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 12, + }, }; #define MXC_JPEG_NUM_FORMATS ARRAY_SIZE(mxc_formats) @@ -437,17 +530,24 @@ static enum mxc_jpeg_image_format mxc_jpeg_fourcc_to_imgfmt(u32 fourcc) { switch (fourcc) { case V4L2_PIX_FMT_GREY: + case V4L2_PIX_FMT_Y012: return MXC_JPEG_GRAY; case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_Y212: return MXC_JPEG_YUV422; case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: + case V4L2_PIX_FMT_P012: + case V4L2_PIX_FMT_P012M: return MXC_JPEG_YUV420; case V4L2_PIX_FMT_YUV24: + case V4L2_PIX_FMT_YUV48_12: return MXC_JPEG_YUV444; case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_BGR48_12: return MXC_JPEG_BGR; case V4L2_PIX_FMT_ABGR32: + case V4L2_PIX_FMT_ABGR64_12: return MXC_JPEG_ABGR; default: return MXC_JPEG_INVALID; @@ -483,6 +583,17 @@ static void mxc_jpeg_addrs(struct mxc_jpeg_desc *desc, offset; } +static bool mxc_jpeg_is_extended_sequential(const struct mxc_jpeg_fmt *fmt) +{ + if (!fmt || !(fmt->flags & MXC_JPEG_FMT_TYPE_RAW)) + return false; + + if (fmt->precision > 8) + return true; + + return false; +} + static void notify_eos(struct mxc_jpeg_ctx *ctx) { const struct v4l2_event ev = { @@ -767,24 +878,31 @@ static int mxc_jpeg_fixup_sof(struct mxc_jpeg_sof *sof, switch (fourcc) { case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: + case V4L2_PIX_FMT_P012: + case V4L2_PIX_FMT_P012M: sof->components_no = 3; sof->comp[0].v = 0x2; sof->comp[0].h = 0x2; break; case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_Y212: sof->components_no = 3; sof->comp[0].v = 0x1; sof->comp[0].h = 0x2; break; case V4L2_PIX_FMT_YUV24: + case V4L2_PIX_FMT_YUV48_12: case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_BGR48_12: default: sof->components_no = 3; break; case V4L2_PIX_FMT_ABGR32: + case V4L2_PIX_FMT_ABGR64_12: sof->components_no = 4; break; case V4L2_PIX_FMT_GREY: + case V4L2_PIX_FMT_Y012: sof->components_no = 1; break; } @@ -804,20 +922,27 @@ static int mxc_jpeg_fixup_sos(struct mxc_jpeg_sos *sos, switch (fourcc) { case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: + case V4L2_PIX_FMT_P012: + case V4L2_PIX_FMT_P012M: sos->components_no = 3; break; case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_Y212: sos->components_no = 3; break; case V4L2_PIX_FMT_YUV24: + case V4L2_PIX_FMT_YUV48_12: case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_BGR48_12: default: sos->components_no = 3; break; case V4L2_PIX_FMT_ABGR32: + case V4L2_PIX_FMT_ABGR64_12: sos->components_no = 4; break; case V4L2_PIX_FMT_GREY: + case V4L2_PIX_FMT_Y012: sos->components_no = 1; break; } @@ -847,12 +972,15 @@ static unsigned int mxc_jpeg_setup_cfg_stream(void *cfg_stream_vaddr, u8 *cfg = (u8 *)cfg_stream_vaddr; struct mxc_jpeg_sof *sof; struct mxc_jpeg_sos *sos; + const struct mxc_jpeg_fmt *fmt = mxc_jpeg_find_format(fourcc); + + if (!fmt) + return 0; memcpy(cfg + offset, jpeg_soi, ARRAY_SIZE(jpeg_soi)); offset += ARRAY_SIZE(jpeg_soi); - if (fourcc == V4L2_PIX_FMT_BGR24 || - fourcc == V4L2_PIX_FMT_ABGR32) { + if (fmt->is_rgb) { memcpy(cfg + offset, jpeg_app14, sizeof(jpeg_app14)); offset += sizeof(jpeg_app14); } else { @@ -918,6 +1046,10 @@ static void mxc_jpeg_config_dec_desc(struct vb2_buffer *out_buf, desc->stm_ctrl &= ~STM_CTRL_IMAGE_FORMAT(0xF); /* clear image format */ desc->stm_ctrl |= STM_CTRL_IMAGE_FORMAT(img_fmt); desc->stm_ctrl |= STM_CTRL_BITBUF_PTR_CLR(1); + if (mxc_jpeg_is_extended_sequential(jpeg_src_buf->fmt)) + desc->stm_ctrl |= STM_CTRL_PIXEL_PRECISION; + else + desc->stm_ctrl &= ~STM_CTRL_PIXEL_PRECISION; desc->line_pitch = q_data_cap->bytesperline[0]; mxc_jpeg_addrs(desc, dst_buf, src_buf, 0); mxc_jpeg_set_bufsize(desc, ALIGN(vb2_plane_size(src_buf, 0), 1024)); From patchwork Wed Mar 22 05:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 666817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60B8FC6FD1F for ; Wed, 22 Mar 2023 05:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbjCVFQ5 (ORCPT ); Wed, 22 Mar 2023 01:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjCVFQz (ORCPT ); Wed, 22 Mar 2023 01:16:55 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2058.outbound.protection.outlook.com [40.107.20.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C715F5A938; Tue, 21 Mar 2023 22:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H7CsSF1yZVHuVbLbZRMD2eHmzAEj/19kGn55qks0KWhRnReGdVaYGVo7SgWXZf0kHtuzBlkFcXS6H4xjIlOzjyXiOKjxP22UDPINyrW48g474v3bmdlHMFCOr+B+LWZ7njT/IFtOQTrBwwCPWWsawmS+3JLfJ9UgjFT8YN3tsSqPuiKJhtYk/zi2TpDzNfv3+6e2bKyPa+5ZZW76psC+klTh/jufdysNGGKGlO/7KtJKeN9aTAquMbiyAPpRlHPs72Pcy7f6Ne4BZ1epWYHccwEaQ14i725d0w8YahuWt9nI5t2i2YWdHw0BKuHZbjlZkWjkkKZxj6I7EMTgvHK+FA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qCAL8779U4zEgsqncy9scuUL8gibGXjTY42SAMO9ens=; b=WQDQs96ZR4MxheiSTSOapwSzV7Tw6DBu6ZZbA2y/DELAMGHhs7KdPUD4wR1L+neDBT5Mm5cWcVkZs2xGCps9zQ+fHZtZo0YpSD0Uadu7z9AA7AWxBqcOLbKkwbznY59X2jqG2oNieUfVnR92PHxJPWsJVDvTY0eLXdOtt/Ag1JTvlB7aHb++DFreI1UQ56h6CcubdnZRKe8dne/qfAdp9aNEl8eg4tDO0czZvNGwRrbHADmBrO3auSls8uFwX9Gzqm4UUn6dm9mBN4NzAr9WZt2RvFoSiEp6aQdcHomTvVDrMyO1z4to3HWvsGxaTfsfW8RzSB5E8fyniFhVO5B/aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qCAL8779U4zEgsqncy9scuUL8gibGXjTY42SAMO9ens=; b=E/E2qae5T10nHaQZxAky4OeFcyNgVoT1mHyn8x61yg0PY6NqxeMtiuX2GDU8VaO/I/TUhSjYOavPEzG0Q4HZ8yn5/bnJSz87EWwi9cfzGVbUzSE7AQgwwpj/K59U93Y+BUtLJOur45FfNeSJfWlSFoyU3qDQqUcnWmdM/tMZhsU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8100.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 05:14:21 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::89aa:9204:790d:e46b%5]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 05:14:21 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 10/10] media: imx-jpeg: Encoder add support for 12bit jpeg Date: Wed, 22 Mar 2023 13:13:13 +0800 Message-Id: <9cb966e5514e01ae826cb70fe1db9c8794b9c1b9.1679461710.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0021.apcprd02.prod.outlook.com (2603:1096:4:1f4::14) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: e94b15f4-0d7d-4d2b-6949-08db2a944b83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HWno1SZ+2Tks3DxlrkV6offRY4Ed/FwCQ2ucINIH9e/g5HUrxg+eIXGyIujKcO+2BlNfqE10TuHx+W4QxrdAu/8h/nrz2Po0yRD2F6jwL5tiIJ+W4fMtb1W1ITDZVD/Fnpxn78T/K8XNSdxX4s5S49y9GXPy7lpvT1YsdUzuO6/hSo3pBfOM1AKD8WH2sfv1U+52uch1CY6zBw7foqdV38A3nhrry+Yb/c+KfN+7gyA5w4H4FZ9eCck9IiObi/tEnTOjaeH44liAQxXF22RIa38ohdJJUrfHTByS0pOMMUboGPvgY1edyqcos937Ki2lyOxJ9BglqjpvtNBLkJki8UV66LVpUYDGnTIkFB9o+IeZBfynNQ2Toz+FvOMyiev3F0m5I+3+rqjQmb2Eq9OH6Yd6E7VS6m3knkEOD1hxBY7u0EuJcr+fUWZQi2LIjPVE5iUYWoGR4mmlfPSLxxApxh55XQiVYq/44lJPoDVsQgwnmkMIqfZRPysYR1CEnYn1pXlTqBjt6pYuOAzly7oJQ1g1VQkmoowvWTTswStT62sRKfcAcLlUCiMJeQA2BSTZGqnfCqJmdHSrleo6BJkpgfJ5JgWBorsOwgQ9Qb6n8CSmZEpRyl+2VpaV9TC4zdCb1Vk+MiwcWOYsXbC6F9RcwYUT4Fi5fgVnrSHLjR/1rfhoxthSJeitYxNbdjeVlYEZaLGjQ1OBK241Z4Ec0aWcpg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199018)(6486002)(66556008)(41300700001)(52116002)(66476007)(7416002)(478600001)(66946007)(5660300002)(8936002)(8676002)(316002)(44832011)(30864003)(4326008)(36756003)(86362001)(6506007)(6512007)(186003)(26005)(6666004)(2616005)(2906002)(38350700002)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s8tTgYW7ACZuB+nMpqRruLNZ8WOI+C06AinzINzTYuHBiWi+kVvQmLFtsntDez2exT5QJ904x05KRWWOPNBfKVfAGJsRPDCEO1yeFkmhf6UD7bXSs/SdBOyzJfAhhIwXsfnQpP+F7Eh8LBAe/C2w/ZVePORNhhJ+zz8Gp9ZMZMg9olWo3ph2Cck/amKrXd3MBz7FW2sLKeE79v9yh23fiJ7w3U0sHBa6+tM4c1UV3QgsCyfN2fxby43qemp+PdHDD3FJVL55WemVtlolEF0drt9xCqLnMfWrYUwLhv9MZfFgZU9Pujn3wjp5aVkTB2wfxItjHk5bwGtepIyZIGm3NutaxFWHy28S2KcpR5uU/ELh3Ql8U8zmcYWiJE3d1ubNP5vPEEC6nVVq8K7X8zcukIEV0ojczSqUzKsqTKGJr9pH2IFg1cBInCMdoBS44PpCQTUEBTl8OKYtQIww8XtnnINC0JWN9VIphGhHFXHptnKFeCYMhVMQgI8E+A6ZQ39jvt0LIj+42zHSMaRFm6eXuNBkP9t9CTqpMj4mgOLkB1NA8szoXNyV/alqqnoXacEBEVwuEuvQnO5glMMxcxRRP8FVM8u+LzvMYqQt/P4uQ+oLbDva6trx4hVA7zNqncoANN1lnK0PzZdVstd7ArWeLvgoVoONPUhKo+dOLeRBUDIAmiEOhlwoeHwx+hSats97zihiZv9GinJ0K8hXYWswSjF+uU8mlJrxSjOQIh7CnSCoufM0MEm1bcux+i7xbctCKFVbWT0dXSHf+AQpOPlYqOjmZ49s1YStSSVqExXCTe4Vy4WCfUy0CbNUfP2P4UJqC6Ri2uVSNbBN+trEQFI4JSZbPnJ7v19NB89B/iBGIGHtLjBv+pPKbbj6Cbuljpgp9BqZrpoSGt6yg1kbJxPzDpfqltkvykaiDoqPUYfWtw3FcYug/cSc5FBZTC1zQexfbx3wi/EGy7iJy0cmixutDXAsfUVwW9ICjEYxqdcJTb9Gzhx3ND6EO7+/w06JJCdZov8y9+5byEtHbZSLIGnWcq+NbEZsB4vAwhlrWhkRY/BtlztAp7qscPs8VVRfOx8dicP/4FzTwxDb2ZyCfx3p2wHtNdqQvDJSR0D4RYHQF5mqzt/8XZeqKtnoD7HUo8zuezeq4NpcFT2LJyKS1ZCMW7a+nPAd87VUzE1aSfbDv0LUNLTZw8aOogeoHQxirhQENyN7mOdCny0CiBa4jDbzCf9kFbNA7oYoAk/79N2fZgwAValt5RtXZMTsFFOu3vGx9HNHZ0hP4wkjuVWFYUxGVrMNk/hvXqib3sICVLF4qf1HluzPXt0qTa/yRl8f+vBpUWg7XxI2GQ+XFwq4ZBu5SqFRMfjagWgRjhNQCXcwAMib4+zKQN+B7lMZhF+lnt3675T0csXBYN0oRMJc6KsoZ0bwUHsu7KPT/1GVfhaEtdUsFW5lhhFoKOM4xH+LFD7d9shpRar+2I9qrC59CFbiXrPa0hQDxl6uROBdZCn9JxKU9+w+KPykA8C2lbAEUFHUKpNbKbaBFM5M5m+EiXJcEc3rY7Ca7J28eoBPLxhpDf5C8INWC+yiFu2VJqawdsdI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e94b15f4-0d7d-4d2b-6949-08db2a944b83 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2023 05:14:21.6143 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eDKQZ1hH227bIPdakYl8/wjYHHRdYzxh/JXZ2TIkKBLhKLyblbdDPxVPHPNPpQA9tD0lQFjq6xK0U1EXRDxCEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org enable encoding 12-bit extended jpeg Signed-off-by: Ming Qian --- .../media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 14 +- .../media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h | 4 +- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 172 +++++++++++++++++- 3 files changed, 175 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c index bbd5d6a9fc86..9a6e8b332e12 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c @@ -97,25 +97,31 @@ void mxc_jpeg_sw_reset(void __iomem *reg) writel(GLB_CTRL_SFT_RST, reg + GLB_CTRL); } -void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg) +void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg, u8 extseq) { dev_dbg(dev, "CAST Encoder CONFIG...\n"); /* * "Config_Mode" enabled, "Config_Mode auto clear enabled", */ - writel(0xa0, reg + CAST_MODE); + if (extseq) + writel(0xb0, reg + CAST_MODE); + else + writel(0xa0, reg + CAST_MODE); /* all markers and segments */ writel(0x3ff, reg + CAST_CFG_MODE); } -void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg) +void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg, u8 extseq) { dev_dbg(dev, "CAST Encoder GO...\n"); /* * "GO" enabled, "GO bit auto clear" enabled */ - writel(0x140, reg + CAST_MODE); + if (extseq) + writel(0x150, reg + CAST_MODE); + else + writel(0x140, reg + CAST_MODE); } void mxc_jpeg_enc_set_quality(struct device *dev, void __iomem *reg, u8 quality) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h index 8b7cd6526efd..ed15ea348f97 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h @@ -117,8 +117,8 @@ void print_wrapper_info(struct device *dev, void __iomem *reg); void mxc_jpeg_sw_reset(void __iomem *reg); int mxc_jpeg_enable(void __iomem *reg); void wait_frmdone(struct device *dev, void __iomem *reg); -void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg); -void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg); +void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg, u8 extseq); +void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg, u8 extseq); void mxc_jpeg_enc_set_quality(struct device *dev, void __iomem *reg, u8 quality); void mxc_jpeg_dec_mode_go(struct device *dev, void __iomem *reg); int mxc_jpeg_get_slot(void __iomem *reg); diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index 74ecc5415aa6..1bf24bf3257d 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -322,6 +322,45 @@ static const unsigned char jpeg_dqt[] = { 0x63, 0x63, 0x63, 0x63, 0x63, 0x63 }; +static const unsigned char jpeg_dqt_extseq[] = { + 0xFF, 0xDB, + 0x01, 0x04, + 0x10, + 0x00, 0x80, 0x00, 0x58, 0x00, 0x60, 0x00, 0x70, + 0x00, 0x60, 0x00, 0x50, 0x00, 0x80, 0x00, 0x70, + 0x00, 0x68, 0x00, 0x70, 0x00, 0x90, 0x00, 0x88, + 0x00, 0x80, 0x00, 0x98, 0x00, 0xC0, 0x01, 0x40, + 0x00, 0xD0, 0x00, 0xC0, 0x00, 0xB0, 0x00, 0xB0, + 0x00, 0xC0, 0x01, 0x88, 0x01, 0x18, 0x01, 0x28, + 0x00, 0xE8, 0x01, 0x40, 0x01, 0xD0, 0x01, 0x98, + 0x01, 0xE8, 0x01, 0xE0, 0x01, 0xC8, 0x01, 0x98, + 0x01, 0xC0, 0x01, 0xB8, 0x02, 0x00, 0x02, 0x40, + 0x02, 0xE0, 0x02, 0x70, 0x02, 0x00, 0x02, 0x20, + 0x02, 0xB8, 0x02, 0x28, 0x01, 0xB8, 0x01, 0xC0, + 0x02, 0x80, 0x03, 0x68, 0x02, 0x88, 0x02, 0xB8, + 0x02, 0xF8, 0x03, 0x10, 0x03, 0x38, 0x03, 0x40, + 0x03, 0x38, 0x01, 0xF0, 0x02, 0x68, 0x03, 0x88, + 0x03, 0xC8, 0x03, 0x80, 0x03, 0x20, 0x03, 0xC0, + 0x02, 0xE0, 0x03, 0x28, 0x03, 0x38, 0x03, 0x18, + 0x11, + 0x00, 0x88, 0x00, 0x90, 0x00, 0x90, 0x00, 0xC0, + 0x00, 0xA8, 0x00, 0xC0, 0x01, 0x78, 0x00, 0xD0, + 0x00, 0xD0, 0x01, 0x78, 0x03, 0x18, 0x02, 0x10, + 0x01, 0xC0, 0x02, 0x10, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, + 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, 0x03, 0x18, +}; + static const unsigned char jpeg_sof_maximal[] = { 0xFF, 0xC0, 0x00, 0x14, 0x08, 0x00, 0x40, 0x00, 0x40, @@ -329,6 +368,13 @@ static const unsigned char jpeg_sof_maximal[] = { 0x03, 0x11, 0x01, 0x04, 0x11, 0x01 }; +static const unsigned char jpeg_sof_extseq[] = { + 0xFF, 0xC1, + 0x00, 0x14, 0x08, 0x00, 0x40, 0x00, 0x40, + 0x04, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, + 0x03, 0x11, 0x01, 0x04, 0x11, 0x01 +}; + static const unsigned char jpeg_dht[] = { 0xFF, 0xC4, 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, @@ -393,6 +439,90 @@ static const unsigned char jpeg_dht[] = { 0xF6, 0xF7, 0xF8, 0xF9, 0xFA }; +static const unsigned char jpeg_dht_extseq[] = { + 0xFF, 0xC4, + 0x02, 0x2a, 0x00, 0x00, 0x01, 0x05, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, + 0x04, 0x03, 0x05, 0x05, 0x02, 0x03, 0x02, + 0x00, 0x00, 0xbf, 0x01, 0x02, 0x03, 0x00, + 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, + 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, + 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, + 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, + 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, + 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, + 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, + 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, + 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, + 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, + 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, + 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, + 0xf7, 0xf8, 0xf9, 0xfa, 0x0b, 0x0c, 0x0d, + 0x0e, 0x1b, 0x1c, 0x1d, 0x1e, 0x2b, 0x2c, + 0x2d, 0x2e, 0x3b, 0x3c, 0x3d, 0x3e, 0x4b, + 0x4c, 0x4d, 0x4e, 0x5b, 0x5c, 0x5d, 0x5e, + 0x6b, 0x6c, 0x6d, 0x6e, 0x7b, 0x7c, 0x7d, + 0x7e, 0x8b, 0x8c, 0x8d, 0x8e, 0x9b, 0x9c, + 0x9d, 0x9e, 0xab, 0xac, 0xad, 0xae, 0xbb, + 0xbc, 0xbd, 0xbe, 0xcb, 0xcc, 0xcd, 0xce, + 0xdb, 0xdc, 0xdd, 0xde, 0xeb, 0xec, 0xed, + 0xee, 0xfb, 0xfc, 0xfd, 0xfe, 0x01, 0x00, + 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x11, 0x00, 0x02, 0x01, + 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, + 0x02, 0x03, 0x02, 0x00, 0x00, 0xbf, 0x01, + 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, + 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, + 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, + 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, + 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, + 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, + 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, + 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, + 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, + 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, + 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, + 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, + 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, + 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, + 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, + 0x0b, 0x0c, 0x0d, 0x0e, 0x1b, 0x1c, 0x1d, + 0x1e, 0x2b, 0x2c, 0x2d, 0x2e, 0x3b, 0x3c, + 0x3d, 0x3e, 0x4b, 0x4c, 0x4d, 0x4e, 0x5b, + 0x5c, 0x5d, 0x5e, 0x6b, 0x6c, 0x6d, 0x6e, + 0x7b, 0x7c, 0x7d, 0x7e, 0x8b, 0x8c, 0x8d, + 0x8e, 0x9b, 0x9c, 0x9d, 0x9e, 0xab, 0xac, + 0xad, 0xae, 0xbb, 0xbc, 0xbd, 0xbe, 0xcb, + 0xcc, 0xcd, 0xce, 0xdb, 0xdc, 0xdd, 0xde, + 0xeb, 0xec, 0xed, 0xee, 0xfb, 0xfc, 0xfd, + 0xfe, +}; + static const unsigned char jpeg_dri[] = { 0xFF, 0xDD, 0x00, 0x04, 0x00, 0x20 @@ -802,7 +932,8 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) if (dec_ret & SLOT_STATUS_ENC_CONFIG_ERR) { u32 ret = readl(reg + CAST_STATUS12); - dev_err(dev, "Encoder/decoder error, status=0x%08x", ret); + dev_err(dev, "Encoder/decoder error, dec_ret = 0x%08x, status=0x%08x", + dec_ret, ret); mxc_jpeg_clr_desc(reg, slot); mxc_jpeg_sw_reset(reg); buf_state = VB2_BUF_STATE_ERROR; @@ -814,10 +945,11 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) if (jpeg->mode == MXC_JPEG_ENCODE && ctx->enc_state == MXC_JPEG_ENC_CONF) { + q_data = mxc_jpeg_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); ctx->enc_state = MXC_JPEG_ENCODING; dev_dbg(dev, "Encoder config finished. Start encoding...\n"); mxc_jpeg_enc_set_quality(dev, reg, ctx->jpeg_quality); - mxc_jpeg_enc_mode_go(dev, reg); + mxc_jpeg_enc_mode_go(dev, reg, mxc_jpeg_is_extended_sequential(q_data->fmt)); goto job_unlock; } if (jpeg->mode == MXC_JPEG_DECODE && jpeg_src_buf->dht_needed) { @@ -868,8 +1000,12 @@ static int mxc_jpeg_fixup_sof(struct mxc_jpeg_sof *sof, u16 w, u16 h) { int sof_length; + const struct mxc_jpeg_fmt *fmt = mxc_jpeg_find_format(fourcc); - sof->precision = 8; /* TODO allow 8/12 bit precision*/ + if (fmt) + sof->precision = fmt->precision; + else + sof->precision = 8; /* TODO allow 8/12 bit precision*/ sof->height = h; _bswap16(&sof->height); sof->width = w; @@ -988,16 +1124,28 @@ static unsigned int mxc_jpeg_setup_cfg_stream(void *cfg_stream_vaddr, offset += sizeof(jpeg_app0); } - memcpy(cfg + offset, jpeg_dqt, sizeof(jpeg_dqt)); - offset += sizeof(jpeg_dqt); + if (mxc_jpeg_is_extended_sequential(fmt)) { + memcpy(cfg + offset, jpeg_dqt_extseq, sizeof(jpeg_dqt_extseq)); + offset += sizeof(jpeg_dqt_extseq); + + memcpy(cfg + offset, jpeg_sof_extseq, sizeof(jpeg_sof_extseq)); + } else { + memcpy(cfg + offset, jpeg_dqt, sizeof(jpeg_dqt)); + offset += sizeof(jpeg_dqt); - memcpy(cfg + offset, jpeg_sof_maximal, sizeof(jpeg_sof_maximal)); + memcpy(cfg + offset, jpeg_sof_maximal, sizeof(jpeg_sof_maximal)); + } offset += 2; /* skip marker ID */ sof = (struct mxc_jpeg_sof *)(cfg + offset); offset += mxc_jpeg_fixup_sof(sof, fourcc, w, h); - memcpy(cfg + offset, jpeg_dht, sizeof(jpeg_dht)); - offset += sizeof(jpeg_dht); + if (mxc_jpeg_is_extended_sequential(fmt)) { + memcpy(cfg + offset, jpeg_dht_extseq, sizeof(jpeg_dht_extseq)); + offset += sizeof(jpeg_dht_extseq); + } else { + memcpy(cfg + offset, jpeg_dht, sizeof(jpeg_dht)); + offset += sizeof(jpeg_dht); + } memcpy(cfg + offset, jpeg_dri, sizeof(jpeg_dri)); offset += sizeof(jpeg_dri); @@ -1138,6 +1286,10 @@ static void mxc_jpeg_config_enc_desc(struct vb2_buffer *out_buf, desc->stm_ctrl = STM_CTRL_CONFIG_MOD(0) | STM_CTRL_IMAGE_FORMAT(img_fmt); desc->stm_ctrl |= STM_CTRL_BITBUF_PTR_CLR(1); + if (mxc_jpeg_is_extended_sequential(q_data->fmt)) + desc->stm_ctrl |= STM_CTRL_PIXEL_PRECISION; + else + desc->stm_ctrl &= ~STM_CTRL_PIXEL_PRECISION; mxc_jpeg_addrs(desc, src_buf, dst_buf, 0); dev_dbg(jpeg->dev, "cfg_desc:\n"); print_descriptor_info(jpeg->dev, cfg_desc); @@ -1338,7 +1490,9 @@ static void mxc_jpeg_device_run(void *priv) ctx->enc_state = MXC_JPEG_ENC_CONF; mxc_jpeg_config_enc_desc(&dst_buf->vb2_buf, ctx, &src_buf->vb2_buf, &dst_buf->vb2_buf); - mxc_jpeg_enc_mode_conf(dev, reg); /* start config phase */ + /* start config phase */ + mxc_jpeg_enc_mode_conf(dev, reg, + mxc_jpeg_is_extended_sequential(q_data_out->fmt)); } else { dev_dbg(dev, "Decoding on slot %d\n", ctx->slot); print_mxc_buf(jpeg, &src_buf->vb2_buf, 0);