xref: /aosp_15_r20/hardware/interfaces/graphics/mapper/2.1/IMapper.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright 2017 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::BufferUsage;
20*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::PixelFormat;
21*4d7e907cSAndroid Build Coastguard Workerimport @2.0::BufferDescriptor;
22*4d7e907cSAndroid Build Coastguard Workerimport @2.0::Error;
23*4d7e907cSAndroid Build Coastguard Workerimport @2.0::IMapper;
24*4d7e907cSAndroid Build Coastguard Worker
25*4d7e907cSAndroid Build Coastguard Workerinterface IMapper extends @2.0::IMapper {
26*4d7e907cSAndroid Build Coastguard Worker    /**
27*4d7e907cSAndroid Build Coastguard Worker     * This is the same as @2.0::IMapper::BufferDescriptorInfo except that it
28*4d7e907cSAndroid Build Coastguard Worker     * accepts @1.1::PixelFormat and @1.1::BufferUsage.
29*4d7e907cSAndroid Build Coastguard Worker     */
30*4d7e907cSAndroid Build Coastguard Worker    struct BufferDescriptorInfo {
31*4d7e907cSAndroid Build Coastguard Worker        /**
32*4d7e907cSAndroid Build Coastguard Worker         * The width specifies how many columns of pixels must be in the
33*4d7e907cSAndroid Build Coastguard Worker         * allocated buffer, but does not necessarily represent the offset in
34*4d7e907cSAndroid Build Coastguard Worker         * columns between the same column in adjacent rows. The rows may be
35*4d7e907cSAndroid Build Coastguard Worker         * padded.
36*4d7e907cSAndroid Build Coastguard Worker         */
37*4d7e907cSAndroid Build Coastguard Worker        uint32_t width;
38*4d7e907cSAndroid Build Coastguard Worker
39*4d7e907cSAndroid Build Coastguard Worker       /**
40*4d7e907cSAndroid Build Coastguard Worker        * The height specifies how many rows of pixels must be in the
41*4d7e907cSAndroid Build Coastguard Worker        * allocated buffer.
42*4d7e907cSAndroid Build Coastguard Worker        */
43*4d7e907cSAndroid Build Coastguard Worker        uint32_t height;
44*4d7e907cSAndroid Build Coastguard Worker
45*4d7e907cSAndroid Build Coastguard Worker       /**
46*4d7e907cSAndroid Build Coastguard Worker        * The number of image layers that must be in the allocated buffer.
47*4d7e907cSAndroid Build Coastguard Worker        */
48*4d7e907cSAndroid Build Coastguard Worker        uint32_t layerCount;
49*4d7e907cSAndroid Build Coastguard Worker
50*4d7e907cSAndroid Build Coastguard Worker        /** Buffer pixel format. */
51*4d7e907cSAndroid Build Coastguard Worker        PixelFormat format;
52*4d7e907cSAndroid Build Coastguard Worker
53*4d7e907cSAndroid Build Coastguard Worker        /**
54*4d7e907cSAndroid Build Coastguard Worker         * Buffer usage mask; valid flags can be found in the definition of
55*4d7e907cSAndroid Build Coastguard Worker         * BufferUsage.
56*4d7e907cSAndroid Build Coastguard Worker         */
57*4d7e907cSAndroid Build Coastguard Worker        bitfield<BufferUsage> usage;
58*4d7e907cSAndroid Build Coastguard Worker    };
59*4d7e907cSAndroid Build Coastguard Worker
60*4d7e907cSAndroid Build Coastguard Worker    /**
61*4d7e907cSAndroid Build Coastguard Worker     * Validate that the buffer can be safely accessed by a caller who assumes
62*4d7e907cSAndroid Build Coastguard Worker     * the specified descriptorInfo and stride. This must at least validate
63*4d7e907cSAndroid Build Coastguard Worker     * that the buffer size is large enough. Validating the buffer against
64*4d7e907cSAndroid Build Coastguard Worker     * individual buffer attributes is optional.
65*4d7e907cSAndroid Build Coastguard Worker     *
66*4d7e907cSAndroid Build Coastguard Worker     * @param buffer is the buffer to validate against.
67*4d7e907cSAndroid Build Coastguard Worker     * @param descriptorInfo specifies the attributes of the buffer.
68*4d7e907cSAndroid Build Coastguard Worker     * @param stride is the buffer stride returned by IAllocator::allocate.
69*4d7e907cSAndroid Build Coastguard Worker     * @return error is NONE upon success. Otherwise,
70*4d7e907cSAndroid Build Coastguard Worker     *                  BAD_BUFFER when the buffer is invalid.
71*4d7e907cSAndroid Build Coastguard Worker     *                  BAD_VALUE when buffer cannot be safely accessed
72*4d7e907cSAndroid Build Coastguard Worker     */
73*4d7e907cSAndroid Build Coastguard Worker    validateBufferSize(pointer buffer,
74*4d7e907cSAndroid Build Coastguard Worker                       BufferDescriptorInfo descriptorInfo,
75*4d7e907cSAndroid Build Coastguard Worker                       uint32_t stride)
76*4d7e907cSAndroid Build Coastguard Worker            generates (Error error);
77*4d7e907cSAndroid Build Coastguard Worker
78*4d7e907cSAndroid Build Coastguard Worker    /**
79*4d7e907cSAndroid Build Coastguard Worker     * Get the transport size of a buffer. An imported buffer handle is a raw
80*4d7e907cSAndroid Build Coastguard Worker     * buffer handle with the process-local runtime data appended. This
81*4d7e907cSAndroid Build Coastguard Worker     * function, for example, allows a caller to omit the process-local
82*4d7e907cSAndroid Build Coastguard Worker     * runtime data at the tail when serializing the imported buffer handle.
83*4d7e907cSAndroid Build Coastguard Worker     *
84*4d7e907cSAndroid Build Coastguard Worker     * Note that a client might or might not omit the process-local runtime
85*4d7e907cSAndroid Build Coastguard Worker     * data when sending an imported buffer handle. The mapper must support
86*4d7e907cSAndroid Build Coastguard Worker     * both cases on the receiving end.
87*4d7e907cSAndroid Build Coastguard Worker     *
88*4d7e907cSAndroid Build Coastguard Worker     * @param buffer is the buffer to get the transport size from.
89*4d7e907cSAndroid Build Coastguard Worker     * @return error is NONE upon success. Otherwise,
90*4d7e907cSAndroid Build Coastguard Worker     *                  BAD_BUFFER when the buffer is invalid.
91*4d7e907cSAndroid Build Coastguard Worker     * @return numFds is the number of file descriptors needed for transport.
92*4d7e907cSAndroid Build Coastguard Worker     * @return numInts is the number of integers needed for transport.
93*4d7e907cSAndroid Build Coastguard Worker     */
94*4d7e907cSAndroid Build Coastguard Worker    getTransportSize(pointer buffer)
95*4d7e907cSAndroid Build Coastguard Worker            generates (Error error,
96*4d7e907cSAndroid Build Coastguard Worker                       uint32_t numFds,
97*4d7e907cSAndroid Build Coastguard Worker                       uint32_t numInts);
98*4d7e907cSAndroid Build Coastguard Worker
99*4d7e907cSAndroid Build Coastguard Worker    /**
100*4d7e907cSAndroid Build Coastguard Worker     * This is the same as @2.0::IMapper::createDescriptor except that it
101*4d7e907cSAndroid Build Coastguard Worker     * accepts @2.1::IMapper::BufferDescriptorInfo.
102*4d7e907cSAndroid Build Coastguard Worker     *
103*4d7e907cSAndroid Build Coastguard Worker     * Creates a buffer descriptor. The descriptor can be used with IAllocator
104*4d7e907cSAndroid Build Coastguard Worker     * to allocate buffers.
105*4d7e907cSAndroid Build Coastguard Worker     *
106*4d7e907cSAndroid Build Coastguard Worker     * Since the buffer descriptor fully describes a buffer, any device
107*4d7e907cSAndroid Build Coastguard Worker     * dependent or device independent checks must be performed here whenever
108*4d7e907cSAndroid Build Coastguard Worker     * possible. Specifically, when layered buffers are not supported, this
109*4d7e907cSAndroid Build Coastguard Worker     * function must return UNSUPPORTED if layerCount is great than 1.
110*4d7e907cSAndroid Build Coastguard Worker     *
111*4d7e907cSAndroid Build Coastguard Worker     * @param descriptorInfo specifies the attributes of the descriptor.
112*4d7e907cSAndroid Build Coastguard Worker     * @return error is NONE upon success. Otherwise,
113*4d7e907cSAndroid Build Coastguard Worker     *                  BAD_VALUE when any of the specified attributes is
114*4d7e907cSAndroid Build Coastguard Worker     *                            invalid or conflicting.
115*4d7e907cSAndroid Build Coastguard Worker     *                  NO_RESOURCES when the creation cannot be fullfilled at
116*4d7e907cSAndroid Build Coastguard Worker     *                               this time.
117*4d7e907cSAndroid Build Coastguard Worker     *                  UNSUPPORTED when any of the specified attributes is
118*4d7e907cSAndroid Build Coastguard Worker     *                              not supported.
119*4d7e907cSAndroid Build Coastguard Worker     * @return descriptor is the newly created buffer descriptor.
120*4d7e907cSAndroid Build Coastguard Worker     */
121*4d7e907cSAndroid Build Coastguard Worker    createDescriptor_2_1(BufferDescriptorInfo descriptorInfo)
122*4d7e907cSAndroid Build Coastguard Worker              generates (Error error,
123*4d7e907cSAndroid Build Coastguard Worker                         BufferDescriptor descriptor);
124*4d7e907cSAndroid Build Coastguard Worker};
125