Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2919377rwb; Sat, 6 Aug 2022 08:39:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7432uNvwoqYvtBGzWjoacuAR1EA4mmZpI2h0U6YeHMfAXUXjAzu2RAfegxDw+MUvsSQG36 X-Received: by 2002:a17:903:1207:b0:16a:7e87:dad3 with SMTP id l7-20020a170903120700b0016a7e87dad3mr11647701plh.99.1659800384372; Sat, 06 Aug 2022 08:39:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659800384; cv=pass; d=google.com; s=arc-20160816; b=LExIapMXodau1/50o4GoWENKLRr5QVYgi8p6n+DeAIDP/hcLWj0qldtmU7rUp+0R1j DHWiVTxj8R/DkBGkrj1Y/AzeZb9txRALyUX93gkMWC9reO2LDuPcNsp6b1CmbbnCM5ZM 4Ir2Xw+IkvoM2uGmCp2b1H/KyhMZOqkdqxI71mOjhh+IhVvNBpkXRFUlktM4aobZ4FDt guIZ0X+HXK/pyWuT6UWlHzbj/txFPBcWndeqv4VqxjyPF/7K41ISBMmhe6WKV+fzDjVV k2dX3bOJOWljyE60jiHGkca4/18NN4C0OfrnRIVYOm7/r2wr3dmcIs8lyqv9y9+czs85 g/AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=4xQ0Ei4B2354OLmFw9W8u7C7od7Dl0Ay2EQaM+jESJk=; b=WM1TcfcLPzv0ApBwy3+7Ii07uIdJJdueAem5eRD9q12kTXqcJoLVICCZRNPjfUEjaM /Bp6euf2A3zhsLlB45jX9gXSq10HKfW5OrsE+OHoZYkX30b+EEacDBs5DlL0Uf13APuR pZpDiz3T98+c0UcrczaxUcmsL1UsyRmxdEIsxg5YYtiA+9K6L70K842WyUijC4v2fnVR lFMJwoGp8hPTTErO+mHG6alCEH8AeZwVM9iFuRDKTY4OXt6sqwiVKGarHXQ4/U/sICQZ A6YTVekBcMPCv5ghMddhTih3Qy9stSesDdMfNn134r5t0CQRQy5AYMk/k69cB4XQ6CxS f3mQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=UnblRbSe; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a170902c40800b0016dc3b5367asi8596466plk.608.2022.08.06.08.39.27; Sat, 06 Aug 2022 08:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=UnblRbSe; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232495AbiHFPXD (ORCPT + 99 others); Sat, 6 Aug 2022 11:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbiHFPXB (ORCPT ); Sat, 6 Aug 2022 11:23:01 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2045.outbound.protection.outlook.com [40.107.94.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D251276C; Sat, 6 Aug 2022 08:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Afbf8ZhLXPpq9GUmju6ZrtTXZa1ecXzIDj3Z6zRpHWYnQKkZ5OZDXs8Ck/aE4kjAr/8eWmOsZGHhvY66hijgXbtfPyPh41iVcIKRA+oPzojj/2Wixd5AB7SvAbRwv4NxqwornP3EQjg53LI5KCB8FVyFP2X2ZVQ7kXI0w7NR+79CygIM8mQ6cjgaeaORJzXz0bnLX1Gv2URNDU5hDaB8Yj4tkFKTumSusQ+H6h5z7Qi9UdFRLkj1wi3A/bEttc/YWusmLE42O+bIfnWyIGt7EVnnmsDNDx673xeqKf4qFtwBz20cLPji7Q05yb86ITaTafPMjq6LtRxP9Ahdbxm4kA== 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=4xQ0Ei4B2354OLmFw9W8u7C7od7Dl0Ay2EQaM+jESJk=; b=Qmlsssb8FSzWNlC5JTF09vL5m/yk0QoHcmOdaqKXyswnbtdqRMx9t9qdOQa9O/zEbepWWWOQNYTepuA4a/Yg4ocvvf8SM8qbbQaSdhBjl1Bt7dxNlL5lcBl4+tlVdL/S57WganZXLSs7Saj5IzeRqih8I3F/wiypVPEkWpg45kmW/AmY2TQ2fdG+efC9kI84xkytqSPDO1EIZp+VYj9IEDMvsm0rMddTPWQsrRk3i0Ch06Ly5V1AX7NcpHswxe1JB93xYo+VB78IZp4KIZZX8/+GBocVLqV6d4ea1iKLP7EOGqljJ6AeW+wvM+9kF+Bg2JqrVI0wbwaKw1h9A2bqNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4xQ0Ei4B2354OLmFw9W8u7C7od7Dl0Ay2EQaM+jESJk=; b=UnblRbSeH3/2TG/sL9XBC0+3ACqgwm88G3a2NA1Ml0EaA7S5nwTe58f93z0N1yacJctUSKQTgxcUtAkRCYduul5osftwggeg6c601SguIxLIb1nyGK0gJZa+Tfcs2IiXQlj6RwyfOmYtcRgLPVOwZHZ1unW1Vq7tfNrN7rm6nLg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=synaptics.com; Received: from DM6PR03MB5196.namprd03.prod.outlook.com (2603:10b6:5:24a::19) by CO1PR03MB5793.namprd03.prod.outlook.com (2603:10b6:303:98::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Sat, 6 Aug 2022 15:22:58 +0000 Received: from DM6PR03MB5196.namprd03.prod.outlook.com ([fe80::c832:eea0:1883:a19c]) by DM6PR03MB5196.namprd03.prod.outlook.com ([fe80::c832:eea0:1883:a19c%3]) with mapi id 15.20.5504.017; Sat, 6 Aug 2022 15:22:58 +0000 Message-ID: <7c7c2c49-a0e4-cda8-be29-0d143851b9fd@synaptics.com> Date: Sat, 6 Aug 2022 23:22:42 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] [Draft]: media: videobuf2-dma-heap: add a vendor defined memory runtine Content-Language: en-US To: Tomasz Figa Cc: linux-media@vger.kernel.org, m.szyprowski@samsung.com, sumit.semwal@linaro.org, christian.koenig@amd.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, ayaka References: From: Hsia-Jun Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BYAPR07CA0006.namprd07.prod.outlook.com (2603:10b6:a02:bc::19) To DM6PR03MB5196.namprd03.prod.outlook.com (2603:10b6:5:24a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70afb110-6b8c-49be-2f07-08da77bf8adb X-MS-TrafficTypeDiagnostic: CO1PR03MB5793:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: il+ALKrKapmh+gSs1phNm1UUic4IzmDOra16phXr4PMSGw0QNeahTZdffMTNT/AncwOuUcKgUD/qdSp6A7du5S2tdF+IpwyrQOlJrFLlLdrJeBfTqNtwddESrh1R7bchwYV3lCnnQNSIJ2FUarjHXdPDDVD2aduetzWg9SH01BJlGsZOe5kA37z8vxZ6ch8huKS8Mb/dnFbOcGFJHXe7J06HqohBaO4u0AC1CJY5BjkBg2khMMF97QkZTuDDC4W08DoiKBxTiXpcuQCj1tyxGo6Aw4lqhfojXXgOALNA5SUA7DhCCFYQC4SpzwL6VoTlwqL5hdslO+BVOA63gSAoZ4AAa86pzfwmgcpOk8O89n5ImavgORJxbER0G01OJUe/o8qtwuAytP051XpVR+O3cxLH7mJUjB1Dl1qFcZRad3s6GXqPbXBV+POSEohiuC0s5Sdkhe8RaGriALOg641h5+BBdMAAT9avTps1JGuHCI5sQd+FEu/YLRZ0WM96dY+Hxxdg0ly35/H6nKvLDzlmFHnuNyMXDVvWSoJOLi34yB1G/2OSv+IPBdeMn6hZc3Q2VpoqLckzw/aOLvYcDBZlQSNJA07lzaa2IPI0QLlgqg3DN+iLLTs1YlDe6zygi1xrOOFphaIrlAsfGSgkMxv2C33HZYYmtlUqHYYTJ5b64qmpMtlaynx+hB7j+QkFQ8XKZ4T69V5TDI7sWnml4eW7IN8o6CoLUDljlEwJj0r5Fy85wHLpIDnrka+kGNRh64oRQbQ99kh/1Wb3fuepp+q1WuMGlrZutdh9lT0WkkG+1Y6EioYckvnwylwj4PVSgfiqvjSfM6czz/zTWJnaw4k5XC+IPIbsG3lMzIS3kyv+fdI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR03MB5196.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(376002)(39850400004)(366004)(136003)(396003)(346002)(83380400001)(8936002)(6916009)(5660300002)(31696002)(26005)(6512007)(86362001)(186003)(2616005)(66556008)(66476007)(4326008)(8676002)(66946007)(316002)(36756003)(31686004)(6506007)(2906002)(478600001)(52116002)(53546011)(41300700001)(6486002)(6666004)(38100700002)(38350700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?S2NSbXovWXRmSjI2d3J2eE90TFp0eFZpQXdBZnRkWGRIWjZsZ2pvajVoMkpV?= =?utf-8?B?Q0RIKzd0YVpLSnVMeUR3MUN5R1JNZFZud1ZUL0UrSUw1Y2F1QWdzb2ljTHhP?= =?utf-8?B?WVM2SDBObm9XK3FqUXNocTNOQndCdnFWam5sQys2VTRJOStCWlBJVHhvWSsz?= =?utf-8?B?dHFiMkpyNEJ3UHFiOUxzUUNiZElxalpXYVhDbW5hcjZITkZxdWVTd1JWMlYy?= =?utf-8?B?SGRTa21nbThDcTNhbzFiakNkTDAvb1NsVGE4QnRCZUlNSytlcUhMaWllWEp6?= =?utf-8?B?SzBib2cyZE13MzcwWXo4Z2FmSzBEZWZtTHNTVGFUQ0FLUU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Q?9s2KxbuQLkyEAsQvHC5rfHvCw?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70afb110-6b8c-49be-2f07-08da77bf8adb X-MS-Exchange-CrossTenant-AuthSource: DM6PR03MB5196.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2022 15:22:57.9362 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ubVbc2ez1J+hg/7LdgmLQ6QJd2dz390dHt6C5iJNLMUk/BhSZZZ+83qcxV1eFfBzJ049d09t0cWOCpB/SenUBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR03MB5793 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/5/22 18:09, Tomasz Figa wrote: > CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe. > > > On Tue, Aug 2, 2022 at 9:21 PM ayaka wrote: >> >> Sorry, the previous one contains html data. >> >>> On Aug 2, 2022, at 3:33 PM, Tomasz Figa wrote: >>> >>> On Mon, Aug 1, 2022 at 8:43 PM ayaka wrote: >>>> Sent from my iPad >>>>>> On Aug 1, 2022, at 5:46 PM, Tomasz Figa wrote: >>>>> CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe. >>>>>> On Mon, Aug 1, 2022 at 3:44 PM Hsia-Jun Li wrote: >>>>>>> On 8/1/22 14:19, Tomasz Figa wrote: >>>>>> Hello Tomasz >>>>>>> ?Hi Randy, >>>>>>> On Mon, Aug 1, 2022 at 5:21 AM wrote: >>>>>>>> From: Randy Li >>>>>>>> This module is still at a early stage, I wrote this for showing what >>>>>>>> APIs we need here. >>>>>>>> Let me explain why we need such a module here. >>>>>>>> If you won't allocate buffers from a V4L2 M2M device, this module >>>>>>>> may not be very useful. I am sure the most of users won't know a >>>>>>>> device would require them allocate buffers from a DMA-Heap then >>>>>>>> import those buffers into a V4L2's queue. >>>>>>>> Then the question goes back to why DMA-Heap. From the Android's >>>>>>>> description, we know it is about the copyright's DRM. >>>>>>>> When we allocate a buffer in a DMA-Heap, it may register that buffer >>>>>>>> in the trusted execution environment so the firmware which is running >>>>>>>> or could only be acccesed from there could use that buffer later. >>>>>>>> The answer above leads to another thing which is not done in this >>>>>>>> version, the DMA mapping. Although in some platforms, a DMA-Heap >>>>>>>> responses a IOMMU device as well. For the genernal purpose, we would >>>>>>>> be better assuming the device mapping should be done for each device >>>>>>>> itself. The problem here we only know alloc_devs in those DMAbuf >>>>>>>> methods, which are DMA-heaps in my design, the device from the queue >>>>>>>> is not enough, a plane may requests another IOMMU device or table >>>>>>>> for mapping. >>>>>>>> Signed-off-by: Randy Li >>>>>>>> --- >>>>>>>> drivers/media/common/videobuf2/Kconfig | 6 + >>>>>>>> drivers/media/common/videobuf2/Makefile | 1 + >>>>>>>> .../common/videobuf2/videobuf2-dma-heap.c | 350 ++++++++++++++++++ >>>>>>>> include/media/videobuf2-dma-heap.h | 30 ++ >>>>>>>> 4 files changed, 387 insertions(+) >>>>>>>> create mode 100644 drivers/media/common/videobuf2/videobuf2-dma-heap.c >>>>>>>> create mode 100644 include/media/videobuf2-dma-heap.h >>>>>>> First of all, thanks for the series. >>>>>>> Possibly a stupid question, but why not just allocate the DMA-bufs >>>>>>> directly from the DMA-buf heap device in the userspace and just import >>>>>>> the buffers to the V4L2 device using V4L2_MEMORY_DMABUF? >>>>>> Sometimes the allocation policy could be very complex, let's suppose a >>>>>> multiple planes pixel format enabling with frame buffer compression. >>>>>> Its luma, chroma data could be allocated from a pool which is delegated >>>>>> for large buffers while its metadata would come from a pool which many >>>>>> users could take some few slices from it(likes system pool). >>>>>> Then when we have a new users knowing nothing about this platform, if we >>>>>> just configure the alloc_devs in each queues well. The user won't need >>>>>> to know those complex rules. >>>>>> The real situation could be more complex, Samsung MFC's left and right >>>>>> banks could be regarded as two pools, many devices would benefit from >>>>>> this either from the allocation times or the security buffers policy. >>>>>> In our design, when we need to do some security decoding(DRM video), >>>>>> codecs2 would allocate buffers from the pool delegated for that. While >>>>>> the non-DRM video, users could not care about this. >>>>> I'm a little bit surprised about this, because on Android all the >>>>> graphics buffers are allocated from the system IAllocator and imported >>>>> to the specific devices. >>>> In the non-tunnel mode, yes it is. While the tunnel mode is completely vendor defined. Neither HWC nor codec2 cares about where the buffers coming from, you could do what ever you want. >>>> Besides there are DRM video in GNU Linux platform, I heard the webkit has made huge effort here and Playready is one could work in non-Android Linux. >>>>> Would it make sense to instead extend the UAPI to expose enough >>>>> information about the allocation requirements to the userspace, so it >>>>> can allocate correctly? >>>> Yes, it could. But as I said it would need the users to do more works. >>>>> My reasoning here is that it's not a driver's decision to allocate >>>>> from a DMA-buf heap (and which one) or not. It's the userspace which >>>>> knows that, based on the specific use case that it wants to fulfill. >>>> Although I would like to let the users decide that, users just can’t do that which would violate the security rules in some platforms. >>>> For example, video codec and display device could only access a region of memory, any other device or trusted apps can’t access it. Users have to allocate the buffer from the pool the vendor decided. >>>> So why not we offer a quick way that users don’t need to try and error. >>> >>> In principle, I'm not against integrating DMA-buf heap with vb2, >>> however I see some problems I mentioned before: >>> >>> 1) How would the driver know if it should allocate from a DMA-buf heap or not? >> >> struct vb2_queue.mem_ops >> >> int (*queue_setup)(struct vb2_queue *q,unsigned int *num_buffers, unsigned int *num_planes, unsigned int sizes[], struct device *alloc_devs[]); > > Sorry, I don't understand what you mean here. > > Just to make sure we're on the same page - what I'm referring to is > that whether DMA-buf heap is used or not is specific to a given use > case, which is controlled by the userspace. So the userspace must be > able to control whether the driver allocates from a DMA-buf heap or > the regular way. No, it does not depend on the use case here. We don't accept any buffers beyond the region we decided. Even for the non-DRM, non-security video, our codec devices are running under the secure mode. You MUST allocate the buffer for a device from the DMA-heap we(SYNA) decided. I believe some other devices may have much limitation for not the security reason, for example, it can't access the memory above 4 GiB or for the performance's reason. > >> >>> 2) How would the driver know which heap to allocate from? >> >> From vb2_queue.alloc_devs >> >> What I did now is likes what MFC does, create some mem_alloc_devs. >> It would be better that we could retrieve the DMA-heaps’ devices from kernel, but that is not enough, we need a place to store the heap flags although none of them are defined yet. >> >> From Android documents, I think it is unlikely we would have heap flags. >> “Standardization: The DMA-BUF heaps framework offers a well-defined UAPI. ION allowed custom flags and heap IDs that prevented developing a common testing framework because each device’s ION implementation could behave differently.” >> > > alloc_devs is something that the driver sets and it's a struct device > for which the DMA API can be called to manage the DMA buffers for this > video device. It's not a way to select a use case-dependent allocation > method. > I see, then move to the last question, we need to expand the V4L2 framework's structure. >>> 3) How would the heap know how to allocate properly for the device? >>> >> Because “each DMA-BUF heap is a separate character device”. > > Could you elaborate? Sorry, I'm not sure how this answers my question. Because a DMA-heap, a heap device itself is enough here, may plus HEAP flag when there is. I don't know what else would be need to do here. If you allocate a buffer from a heap which is delegated for security memory of that device, the heap driver itself would inform the TEE the pages occupied by it or the memory allocated from the pool which is in a region of memory reserved for this purpose. > >> But as I said in the first draft I am not sure about the DMA mapping part. alloc_devs responds for the heap, we have a device variable in the queue that mapping function could access, but that may not be enough. A plane may apply a different mapping policy or IOMMU here. >> >> Would it be better that I create a interface here that creating a memdev with DMA-heap description ? > > My intuition still tells me that it would be universally better to > just let the userspace allocate the buffers independently (like with > gralloc/Ion) and import to V4L2 using V4L2_MEM_DMABUF. It was possible > to do things this way nicely with regular Android graphics buffers, so > could you explain what difference of your use case makes it > impossible? Without keeping the backward compatibility, it won't have any problem IF we could tell the users the acceptable DMA-heap for each of planes and DMA-heap's heap flags. We don't have an ioctl for this yet, the most possible for the decoder is doing that at GET_FMT ioctl()?. > > Best regards, > Tomasz P.S. we would disclose our pixel formats soon, it could offer more information here. --- Sincerely Hsia-Jun(Randy) Li