OSDN Git Service

Merge "graphics: revise gralloc interfaces" into oc-dev
[android-x86/hardware-interfaces.git] / graphics / common / 1.0 / types.hal
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package android.hardware.graphics.common@1.0;
18
19 /**
20  * pixel format definitions
21  */
22 @export(name="android_pixel_format_t", value_prefix="HAL_PIXEL_FORMAT_")
23 enum PixelFormat : int32_t {
24     /**
25      * "linear" color pixel formats:
26      *
27      * When used with ANativeWindow, the dataSpace field describes the color
28      * space of the buffer.
29      *
30      * The color space determines, for example, if the formats are linear or
31      * gamma-corrected; or whether any special operations are performed when
32      * reading or writing into a buffer in one of these formats.
33      */
34     RGBA_8888          = 1,
35     RGBX_8888          = 2,
36     RGB_888            = 3,
37     RGB_565            = 4,
38     BGRA_8888          = 5,
39
40     /**
41      * The following formats use 10bit integers for R, G, and B and
42      * 2 bits for alpha. This is used to improve color precision on
43      * wide-color devices, e.g. Display-P3 or scRGB.
44      *
45      * When used with ANativeWindow, the dataSpace field describes the color
46      * space of the buffer.
47      */
48     RGBA_1010102       = 0x2B,
49
50     /**
51      * The following formats use a 16bit float per color component.
52      *
53      * When used with ANativeWindow, the dataSpace field describes the color
54      * space of the buffer.
55      */
56     RGBA_FP16          = 0x16,
57
58     /**
59      * 0x101 - 0x1FF
60      *
61      * This range is reserved for pixel formats that are specific to the HAL
62      * implementation.  Implementations can use any value in this range to
63      * communicate video pixel formats between their HAL modules.  These formats
64      * must not have an alpha channel.  Additionally, an EGLimage created from a
65      * gralloc buffer of one of these formats must be supported for use with the
66      * GL_OES_EGL_image_external OpenGL ES extension.
67      */
68
69     /**
70      * Android YUV format:
71      *
72      * This format is exposed outside of the HAL to software decoders and
73      * applications.  EGLImageKHR must support it in conjunction with the
74      * OES_EGL_image_external extension.
75      *
76      * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
77      * by (W/2) x (H/2) Cr and Cb planes.
78      *
79      * This format assumes
80      * - an even width
81      * - an even height
82      * - a horizontal stride multiple of 16 pixels
83      * - a vertical stride equal to the height
84      *
85      *   y_size = stride * height
86      *   c_stride = ALIGN(stride/2, 16)
87      *   c_size = c_stride * height/2
88      *   size = y_size + c_size * 2
89      *   cr_offset = y_size
90      *   cb_offset = y_size + c_size
91      *
92      * When used with ANativeWindow, the dataSpace field describes the color
93      * space of the buffer.
94      */
95     YV12   = 0x32315659, // YCrCb 4:2:0 Planar
96
97
98     /**
99      * Android Y8 format:
100      *
101      * This format is exposed outside of the HAL to the framework.
102      * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
103      * and no other HW_ flags will be used.
104      *
105      * Y8 is a YUV planar format comprised of a WxH Y plane,
106      * with each pixel being represented by 8 bits.
107      *
108      * It is equivalent to just the Y plane from YV12.
109      *
110      * This format assumes
111      * - an even width
112      * - an even height
113      * - a horizontal stride multiple of 16 pixels
114      * - a vertical stride equal to the height
115      *
116      *   size = stride * height
117      *
118      * When used with ANativeWindow, the dataSpace field describes the color
119      * space of the buffer.
120      */
121     Y8     = 0x20203859,
122
123     /**
124      * Android Y16 format:
125      *
126      * This format is exposed outside of the HAL to the framework.
127      * The expected gralloc usage flags are SW_* and HW_CAMERA_*,
128      * and no other HW_ flags will be used.
129      *
130      * Y16 is a YUV planar format comprised of a WxH Y plane,
131      * with each pixel being represented by 16 bits.
132      *
133      * It is just like Y8, but has double the bits per pixel (little endian).
134      *
135      * This format assumes
136      * - an even width
137      * - an even height
138      * - a horizontal stride multiple of 16 pixels
139      * - a vertical stride equal to the height
140      * - strides are specified in pixels, not in bytes
141      *
142      *   size = stride * height * 2
143      *
144      * When used with ANativeWindow, the dataSpace field describes the color
145      * space of the buffer, except that dataSpace field
146      * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth
147      * image where each sample is a distance value measured by a depth camera,
148      * plus an associated confidence value.
149      */
150     Y16    = 0x20363159,
151
152     /**
153      * Android RAW sensor format:
154      *
155      * This format is exposed outside of the camera HAL to applications.
156      *
157      * RAW16 is a single-channel, 16-bit, little endian format, typically
158      * representing raw Bayer-pattern images from an image sensor, with minimal
159      * processing.
160      *
161      * The exact pixel layout of the data in the buffer is sensor-dependent, and
162      * needs to be queried from the camera device.
163      *
164      * Generally, not all 16 bits are used; more common values are 10 or 12
165      * bits. If not all bits are used, the lower-order bits are filled first.
166      * All parameters to interpret the raw data (black and white points,
167      * color space, etc) must be queried from the camera device.
168      *
169      * This format assumes
170      * - an even width
171      * - an even height
172      * - a horizontal stride multiple of 16 pixels
173      * - a vertical stride equal to the height
174      * - strides are specified in pixels, not in bytes
175      *
176      *   size = stride * height * 2
177      *
178      * This format must be accepted by the gralloc module when used with the
179      * following usage flags:
180      *    - GRALLOC_USAGE_HW_CAMERA_*
181      *    - GRALLOC_USAGE_SW_*
182      *    - GRALLOC_USAGE_RENDERSCRIPT
183      *
184      * When used with ANativeWindow, the mapping of the dataSpace field to
185      * buffer contents for RAW16 is as follows:
186      *
187      *  dataSpace value               | Buffer contents
188      * -------------------------------+-----------------------------------------
189      *  HAL_DATASPACE_ARBITRARY       | Raw image sensor data, layout is as
190      *                                | defined above.
191      *  HAL_DATASPACE_DEPTH           | Unprocessed implementation-dependent raw
192      *                                | depth measurements, opaque with 16 bit
193      *                                | samples.
194      *  Other                         | Unsupported
195      */
196     RAW16 = 0x20,
197
198     /**
199      * Android RAW10 format:
200      *
201      * This format is exposed outside of the camera HAL to applications.
202      *
203      * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row,
204      * unprocessed format, usually representing raw Bayer-pattern images coming from
205      * an image sensor.
206      *
207      * In an image buffer with this format, starting from the first pixel of each
208      * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one
209      * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte
210      * contains the 2 least significant bits of the 4 pixels, the exact layout data
211      * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth
212      * bit of the ith pixel):
213      *
214      *          bit 7                                     bit 0
215      *          =====|=====|=====|=====|=====|=====|=====|=====|
216      * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]|
217      *         |-----|-----|-----|-----|-----|-----|-----|-----|
218      * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]|
219      *         |-----|-----|-----|-----|-----|-----|-----|-----|
220      * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]|
221      *         |-----|-----|-----|-----|-----|-----|-----|-----|
222      * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]|
223      *         |-----|-----|-----|-----|-----|-----|-----|-----|
224      * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]|
225      *          ===============================================
226      *
227      * This format assumes
228      * - a width multiple of 4 pixels
229      * - an even height
230      * - a vertical stride equal to the height
231      * - strides are specified in bytes, not in pixels
232      *
233      *   size = stride * height
234      *
235      * When stride is equal to width * (10 / 8), there will be no padding bytes at
236      * the end of each row, the entire image data is densely packed. When stride is
237      * larger than width * (10 / 8), padding bytes will be present at the end of each
238      * row (including the last row).
239      *
240      * This format must be accepted by the gralloc module when used with the
241      * following usage flags:
242      *    - GRALLOC_USAGE_HW_CAMERA_*
243      *    - GRALLOC_USAGE_SW_*
244      *    - GRALLOC_USAGE_RENDERSCRIPT
245      *
246      * When used with ANativeWindow, the dataSpace field should be
247      * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
248      * extra metadata to define.
249      */
250     RAW10 = 0x25,
251
252     /**
253      * Android RAW12 format:
254      *
255      * This format is exposed outside of camera HAL to applications.
256      *
257      * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row,
258      * unprocessed format, usually representing raw Bayer-pattern images coming from
259      * an image sensor.
260      *
261      * In an image buffer with this format, starting from the first pixel of each
262      * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
263      * and second byte contains the top 8 bits of first and second pixel. The third
264      * byte contains the 4 least significant bits of the two pixels, the exact layout
265      * data for each two consecutive pixels is illustrated below (Pi[j] stands for
266      * the jth bit of the ith pixel):
267      *
268      *           bit 7                                            bit 0
269      *          ======|======|======|======|======|======|======|======|
270      * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]|
271      *         |------|------|------|------|------|------|------|------|
272      * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]|
273      *         |------|------|------|------|------|------|------|------|
274      * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]|
275      *          =======================================================
276      *
277      * This format assumes:
278      * - a width multiple of 4 pixels
279      * - an even height
280      * - a vertical stride equal to the height
281      * - strides are specified in bytes, not in pixels
282      *
283      *   size = stride * height
284      *
285      * When stride is equal to width * (12 / 8), there will be no padding bytes at
286      * the end of each row, the entire image data is densely packed. When stride is
287      * larger than width * (12 / 8), padding bytes will be present at the end of
288      * each row (including the last row).
289      *
290      * This format must be accepted by the gralloc module when used with the
291      * following usage flags:
292      *    - GRALLOC_USAGE_HW_CAMERA_*
293      *    - GRALLOC_USAGE_SW_*
294      *    - GRALLOC_USAGE_RENDERSCRIPT
295      *
296      * When used with ANativeWindow, the dataSpace field should be
297      * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
298      * extra metadata to define.
299      */
300     RAW12 = 0x26,
301
302     /**
303      * Android opaque RAW format:
304      *
305      * This format is exposed outside of the camera HAL to applications.
306      *
307      * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an
308      * image sensor. The actual structure of buffers of this format is
309      * implementation-dependent.
310      *
311      * This format must be accepted by the gralloc module when used with the
312      * following usage flags:
313      *    - GRALLOC_USAGE_HW_CAMERA_*
314      *    - GRALLOC_USAGE_SW_*
315      *    - GRALLOC_USAGE_RENDERSCRIPT
316      *
317      * When used with ANativeWindow, the dataSpace field should be
318      * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
319      * extra metadata to define.
320      */
321     RAW_OPAQUE = 0x24,
322
323     /**
324      * Android binary blob graphics buffer format:
325      *
326      * This format is used to carry task-specific data which does not have a
327      * standard image structure. The details of the format are left to the two
328      * endpoints.
329      *
330      * A typical use case is for transporting JPEG-compressed images from the
331      * Camera HAL to the framework or to applications.
332      *
333      * Buffers of this format must have a height of 1, and width equal to their
334      * size in bytes.
335      *
336      * When used with ANativeWindow, the mapping of the dataSpace field to
337      * buffer contents for BLOB is as follows:
338      *
339      *  dataSpace value               | Buffer contents
340      * -------------------------------+-----------------------------------------
341      *  HAL_DATASPACE_JFIF            | An encoded JPEG image
342      *  HAL_DATASPACE_DEPTH           | An android_depth_points buffer
343      *  HAL_DATASPACE_SENSOR          | Sensor event data.
344      *  Other                         | Unsupported
345      *
346      */
347     BLOB = 0x21,
348
349     /**
350      * Android format indicating that the choice of format is entirely up to the
351      * device-specific Gralloc implementation.
352      *
353      * The Gralloc implementation should examine the usage bits passed in when
354      * allocating a buffer with this format, and it should derive the pixel
355      * format from those usage flags.  This format will never be used with any
356      * of the GRALLOC_USAGE_SW_* usage flags.
357      *
358      * If a buffer of this format is to be used as an OpenGL ES texture, the
359      * framework will assume that sampling the texture will always return an
360      * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
361      *
362      * When used with ANativeWindow, the dataSpace field describes the color
363      * space of the buffer.
364      */
365     IMPLEMENTATION_DEFINED = 0x22,
366
367     /**
368      * Android flexible YCbCr 4:2:0 formats
369      *
370      * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0
371      * buffer layout, while still describing the general format in a
372      * layout-independent manner.  While called YCbCr, it can be
373      * used to describe formats with either chromatic ordering, as well as
374      * whole planar or semiplanar layouts.
375      *
376      * struct android_ycbcr (below) is the the struct used to describe it.
377      *
378      * This format must be accepted by the gralloc module when
379      * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set.
380      *
381      * This format is locked for use by gralloc's (*lock_ycbcr) method, and
382      * locking with the (*lock) method will return an error.
383      *
384      * When used with ANativeWindow, the dataSpace field describes the color
385      * space of the buffer.
386      */
387     YCBCR_420_888 = 0x23,
388
389     /**
390      * Android flexible YCbCr 4:2:2 formats
391      *
392      * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2
393      * buffer layout, while still describing the general format in a
394      * layout-independent manner.  While called YCbCr, it can be
395      * used to describe formats with either chromatic ordering, as well as
396      * whole planar or semiplanar layouts.
397      *
398      * This format is currently only used by SW readable buffers
399      * produced by MediaCodecs, so the gralloc module can ignore this format.
400      */
401     YCBCR_422_888 = 0x27,
402
403     /**
404      * Android flexible YCbCr 4:4:4 formats
405      *
406      * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4
407      * buffer layout, while still describing the general format in a
408      * layout-independent manner.  While called YCbCr, it can be
409      * used to describe formats with either chromatic ordering, as well as
410      * whole planar or semiplanar layouts.
411      *
412      * This format is currently only used by SW readable buffers
413      * produced by MediaCodecs, so the gralloc module can ignore this format.
414      */
415     YCBCR_444_888 = 0x28,
416
417     /**
418      * Android flexible RGB 888 formats
419      *
420      * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX
421      * buffer layout, while still describing the general format in a
422      * layout-independent manner.  While called RGB, it can be
423      * used to describe formats with either color ordering and optional
424      * padding, as well as whole planar layout.
425      *
426      * This format is currently only used by SW readable buffers
427      * produced by MediaCodecs, so the gralloc module can ignore this format.
428      */
429     FLEX_RGB_888 = 0x29,
430
431     /**
432      * Android flexible RGBA 8888 formats
433      *
434      * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR
435      * buffer layout, while still describing the general format in a
436      * layout-independent manner.  While called RGBA, it can be
437      * used to describe formats with any of the component orderings, as
438      * well as whole planar layout.
439      *
440      * This format is currently only used by SW readable buffers
441      * produced by MediaCodecs, so the gralloc module can ignore this format.
442      */
443     FLEX_RGBA_8888 = 0x2A,
444
445     /** Legacy formats (deprecated), used by ImageFormat.java */
446     YCBCR_422_SP       = 0x10,  // NV16
447     YCRCB_420_SP       = 0x11,  // NV21
448     YCBCR_422_I        = 0x14,  // YUY2
449     JPEG               = 0x100,
450 };
451
452 /**
453  * Buffer usage definitions.
454  */
455 enum BufferUsage : uint64_t {
456     /** bit 0-3 is an enum */
457     CPU_READ_MASK   = 0xfULL,
458     /** buffer is never read by CPU */
459     CPU_READ_NEVER  = 0,
460     /** buffer is rarely read by CPU */
461     CPU_READ_RARELY = 2,
462     /** buffer is often read by CPU */
463     CPU_READ_OFTEN  = 3,
464
465     /** bit 4-7 is an enum */
466     CPU_WRITE_MASK   = 0xfULL << 4,
467     /** buffer is never written by CPU */
468     CPU_WRITE_NEVER  = 0 << 4,
469     /** buffer is rarely written by CPU */
470     CPU_WRITE_RARELY = 2 << 4,
471     /** buffer is often written by CPU */
472     CPU_WRITE_OFTEN  = 3 << 4,
473
474     /** buffer is used as a GPU texture */
475     GPU_TEXTURE       = 1ULL << 8,
476
477     /** buffer is used as a GPU render target */
478     GPU_RENDER_TARGET = 1ULL << 9,
479
480     /** bit 10 must be zero */
481
482     /** buffer is used as a composer HAL overlay layer */
483     COMPOSER_OVERLAY  = 1ULL << 11,
484     /** buffer is used as a composer HAL client target */
485     COMPOSER_CLIENT_TARGET = 1ULL << 12,
486
487     /** bit 13 must be zero */
488
489     /**
490      * Buffer is allocated with hardware-level protection against copying the
491      * contents (or information derived from the contents) into unprotected
492      * memory.
493      */
494     PROTECTED         = 1ULL << 14,
495
496     /** buffer is used as a hwcomposer HAL cursor layer */
497     COMPOSER_CURSOR   = 1ULL << 15,
498
499     /** buffer is used as a video encoder input */
500     VIDEO_ENCODER     = 1ULL << 16,
501
502     /** buffer is used as a camera HAL output */
503     CAMERA_OUTPUT     = 1ULL << 17,
504
505     /** buffer is used as a camera HAL input */
506     CAMERA_INPUT      = 1ULL << 18,
507
508     /** bit 19 must be zero */
509
510     /** buffer is used as a renderscript allocation */
511     RENDERSCRIPT      = 1ULL << 20,
512
513     /** bit 21 must be zero */
514
515     /** buffer is used as a video decoder output */
516     VIDEO_DECODER     = 1ULL << 22,
517
518     /** buffer is used as a sensor direct report output */
519     SENSOR_DIRECT_DATA = 1ULL << 23,
520
521     /**
522      * buffer is used as as an OpenGL shader storage or uniform
523      * buffer object
524      */
525     GPU_DATA_BUFFER   = 1ULL << 24,
526
527     /** bits 25-27 must be zero and are reserved for future versions */
528     /** bits 28-31 are reserved for vendor extensions */
529     VENDOR_MASK       = 0xfULL << 28,
530
531     /** bits 32-47 must be zero and are reserved for future versions */
532     /** bits 48-63 are reserved for vendor extensions */
533     VENDOR_MASK_HI    = 0xffffULL << 48,
534 };
535
536 /**
537  * Transformation definitions
538  *
539  * IMPORTANT NOTE:
540  * ROT_90 is applied CLOCKWISE and AFTER FLIP_{H|V}.
541  *
542  */
543 @export(name="android_transform_t", value_prefix="HAL_TRANSFORM_")
544 enum Transform : int32_t {
545     /** flip source image horizontally (around the vertical axis) */
546     FLIP_H    = 0x01,
547     /**
548      * flip source image vertically (around the horizontal axis)*/
549     FLIP_V    = 0x02,
550     /** rotate source image 90 degrees clockwise */
551     ROT_90    = 0x04,
552     /** rotate source image 180 degrees */
553     ROT_180   = 0x03,
554     /** rotate source image 270 degrees clockwise */
555     ROT_270   = 0x07,
556
557     /** 0x08 is reserved */
558 };
559
560 /**
561  * Dataspace Definitions
562  * ======================
563  *
564  * Dataspace is the definition of how pixel values should be interpreted.
565  *
566  * For many formats, this is the colorspace of the image data, which includes
567  * primaries (including white point) and the transfer characteristic function,
568  * which describes both gamma curve and numeric range (within the bit depth).
569  *
570  * Other dataspaces include depth measurement data from a depth camera.
571  *
572  * A dataspace is comprised of a number of fields.
573  *
574  * Version
575  * --------
576  * The top 2 bits represent the revision of the field specification. This is
577  * currently always 0.
578  *
579  *
580  * bits    31-30 29                      -                          0
581  *        +-----+----------------------------------------------------+
582  * fields | Rev |            Revision specific fields                |
583  *        +-----+----------------------------------------------------+
584  *
585  * Field layout for version = 0:
586  * ----------------------------
587  *
588  * A dataspace is comprised of the following fields:
589  *      Standard
590  *      Transfer function
591  *      Range
592  *
593  * bits    31-30 29-27 26 -  22 21 -  16 15             -           0
594  *        +-----+-----+--------+--------+----------------------------+
595  * fields |  0  |Range|Transfer|Standard|    Legacy and custom       |
596  *        +-----+-----+--------+--------+----------------------------+
597  *          VV    RRR   TTTTT    SSSSSS    LLLLLLLL       LLLLLLLL
598  *
599  * If range, transfer and standard fields are all 0 (e.g. top 16 bits are
600  * all zeroes), the bottom 16 bits contain either a legacy dataspace value,
601  * or a custom value.
602  */
603 @export(name="android_dataspace_t", value_prefix="HAL_DATASPACE_")
604 enum Dataspace : int32_t {
605     /**
606      * Default-assumption data space, when not explicitly specified.
607      *
608      * It is safest to assume the buffer is an image with sRGB primaries and
609      * encoding ranges, but the consumer and/or the producer of the data may
610      * simply be using defaults. No automatic gamma transform should be
611      * expected, except for a possible display gamma transform when drawn to a
612      * screen.
613      */
614     UNKNOWN = 0x0,
615
616     /**
617      * Arbitrary dataspace with manually defined characteristics.  Definition
618      * for colorspaces or other meaning must be communicated separately.
619      *
620      * This is used when specifying primaries, transfer characteristics,
621      * etc. separately.
622      *
623      * A typical use case is in video encoding parameters (e.g. for H.264),
624      * where a colorspace can have separately defined primaries, transfer
625      * characteristics, etc.
626      */
627     ARBITRARY = 0x1,
628
629     /**
630      * Color-description aspects
631      *
632      * The following aspects define various characteristics of the color
633      * specification. These represent bitfields, so that a data space value
634      * can specify each of them independently.
635      */
636
637     STANDARD_SHIFT = 16,
638
639     /**
640      * Standard aspect
641      *
642      * Defines the chromaticity coordinates of the source primaries in terms of
643      * the CIE 1931 definition of x and y specified in ISO 11664-1.
644      */
645     STANDARD_MASK = 63 << STANDARD_SHIFT,  // 0x3F
646
647     /**
648      * Chromacity coordinates are unknown or are determined by the application.
649      * Implementations shall use the following suggested standards:
650      *
651      * All YCbCr formats: BT709 if size is 720p or larger (since most video
652      *                    content is letterboxed this corresponds to width is
653      *                    1280 or greater, or height is 720 or greater).
654      *                    BT601_625 if size is smaller than 720p or is JPEG.
655      * All RGB formats:   BT709.
656      *
657      * For all other formats standard is undefined, and implementations should use
658      * an appropriate standard for the data represented.
659      */
660     STANDARD_UNSPECIFIED = 0 << STANDARD_SHIFT,
661
662     /**
663      * Primaries:       x       y
664      *  green           0.300   0.600
665      *  blue            0.150   0.060
666      *  red             0.640   0.330
667      *  white (D65)     0.3127  0.3290
668      *
669      * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation
670      * for RGB conversion.
671      */
672     STANDARD_BT709 = 1 << STANDARD_SHIFT,
673
674     /**
675      * Primaries:       x       y
676      *  green           0.290   0.600
677      *  blue            0.150   0.060
678      *  red             0.640   0.330
679      *  white (D65)     0.3127  0.3290
680      *
681      *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
682      *  for RGB conversion from the one purely determined by the primaries
683      *  to minimize the color shift into RGB space that uses BT.709
684      *  primaries.
685      */
686     STANDARD_BT601_625 = 2 << STANDARD_SHIFT,
687
688     /**
689      * Primaries:       x       y
690      *  green           0.290   0.600
691      *  blue            0.150   0.060
692      *  red             0.640   0.330
693      *  white (D65)     0.3127  0.3290
694      *
695      * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
696      * for RGB conversion.
697      */
698     STANDARD_BT601_625_UNADJUSTED = 3 << STANDARD_SHIFT,
699
700     /**
701      * Primaries:       x       y
702      *  green           0.310   0.595
703      *  blue            0.155   0.070
704      *  red             0.630   0.340
705      *  white (D65)     0.3127  0.3290
706      *
707      *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
708      *  for RGB conversion from the one purely determined by the primaries
709      *  to minimize the color shift into RGB space that uses BT.709
710      *  primaries.
711      */
712     STANDARD_BT601_525 = 4 << STANDARD_SHIFT,
713
714     /**
715      * Primaries:       x       y
716      *  green           0.310   0.595
717      *  blue            0.155   0.070
718      *  red             0.630   0.340
719      *  white (D65)     0.3127  0.3290
720      *
721      * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
722      * for RGB conversion (as in SMPTE 240M).
723      */
724     STANDARD_BT601_525_UNADJUSTED = 5 << STANDARD_SHIFT,
725
726     /**
727      * Primaries:       x       y
728      *  green           0.170   0.797
729      *  blue            0.131   0.046
730      *  red             0.708   0.292
731      *  white (D65)     0.3127  0.3290
732      *
733      * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
734      * for RGB conversion.
735      */
736     STANDARD_BT2020 = 6 << STANDARD_SHIFT,
737
738     /**
739      * Primaries:       x       y
740      *  green           0.170   0.797
741      *  blue            0.131   0.046
742      *  red             0.708   0.292
743      *  white (D65)     0.3127  0.3290
744      *
745      * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
746      * for RGB conversion using the linear domain.
747      */
748     STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << STANDARD_SHIFT,
749
750     /**
751      * Primaries:       x      y
752      *  green           0.21   0.71
753      *  blue            0.14   0.08
754      *  red             0.67   0.33
755      *  white (C)       0.310  0.316
756      *
757      * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation
758      * for RGB conversion.
759      */
760     STANDARD_BT470M = 8 << STANDARD_SHIFT,
761
762     /**
763      * Primaries:       x       y
764      *  green           0.243   0.692
765      *  blue            0.145   0.049
766      *  red             0.681   0.319
767      *  white (C)       0.310   0.316
768      *
769      * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation
770      * for RGB conversion.
771      */
772     STANDARD_FILM = 9 << STANDARD_SHIFT,
773
774     /**
775      * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3)
776      * Primaries:       x       y
777      *  green           0.265   0.690
778      *  blue            0.150   0.060
779      *  red             0.680   0.320
780      *  white (D65)     0.3127  0.3290
781      */
782     STANDARD_DCI_P3 = 10 << STANDARD_SHIFT,
783
784     /**
785      * Adobe RGB
786      * Primaries:       x       y
787      *  green           0.210   0.710
788      *  blue            0.150   0.060
789      *  red             0.640   0.330
790      *  white (D65)     0.3127  0.3290
791      */
792     STANDARD_ADOBE_RGB = 11 << STANDARD_SHIFT,
793
794
795
796     TRANSFER_SHIFT = 22,
797
798     /**
799      * Transfer aspect
800      *
801      * Transfer characteristics are the opto-electronic transfer characteristic
802      * at the source as a function of linear optical intensity (luminance).
803      *
804      * For digital signals, E corresponds to the recorded value. Normally, the
805      * transfer function is applied in RGB space to each of the R, G and B
806      * components independently. This may result in color shift that can be
807      * minized by applying the transfer function in Lab space only for the L
808      * component. Implementation may apply the transfer function in RGB space
809      * for all pixel formats if desired.
810      */
811
812     TRANSFER_MASK = 31 << TRANSFER_SHIFT,  // 0x1F
813
814     /**
815      * Transfer characteristics are unknown or are determined by the
816      * application.
817      *
818      * Implementations should use the following transfer functions:
819      *
820      * For YCbCr formats: use TRANSFER_SMPTE_170M
821      * For RGB formats: use TRANSFER_SRGB
822      *
823      * For all other formats transfer function is undefined, and implementations
824      * should use an appropriate standard for the data represented.
825      */
826     TRANSFER_UNSPECIFIED = 0 << TRANSFER_SHIFT,
827
828     /**
829      * Transfer characteristic curve:
830      *  E = L
831      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
832      *      E - corresponding electrical signal
833      */
834     TRANSFER_LINEAR = 1 << TRANSFER_SHIFT,
835
836     /**
837      * Transfer characteristic curve:
838      *
839      * E = 1.055 * L^(1/2.4) - 0.055  for 0.0031308 <= L <= 1
840      *   = 12.92 * L                  for 0 <= L < 0.0031308
841      *     L - luminance of image 0 <= L <= 1 for conventional colorimetry
842      *     E - corresponding electrical signal
843      */
844     TRANSFER_SRGB = 2 << TRANSFER_SHIFT,
845
846     /**
847      * BT.601 525, BT.601 625, BT.709, BT.2020
848      *
849      * Transfer characteristic curve:
850      *  E = 1.099 * L ^ 0.45 - 0.099  for 0.018 <= L <= 1
851      *    = 4.500 * L                 for 0 <= L < 0.018
852      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
853      *      E - corresponding electrical signal
854      */
855     TRANSFER_SMPTE_170M = 3 << TRANSFER_SHIFT,
856
857     /**
858      * Assumed display gamma 2.2.
859      *
860      * Transfer characteristic curve:
861      *  E = L ^ (1/2.2)
862      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
863      *      E - corresponding electrical signal
864      */
865     TRANSFER_GAMMA2_2 = 4 << TRANSFER_SHIFT,
866
867     /**
868      *  display gamma 2.6.
869      *
870      * Transfer characteristic curve:
871      *  E = L ^ (1/2.6)
872      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
873      *      E - corresponding electrical signal
874      */
875     TRANSFER_GAMMA2_6 = 5 << TRANSFER_SHIFT,
876
877     /**
878      *  display gamma 2.8.
879      *
880      * Transfer characteristic curve:
881      *  E = L ^ (1/2.8)
882      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
883      *      E - corresponding electrical signal
884      */
885     TRANSFER_GAMMA2_8 = 6 << TRANSFER_SHIFT,
886
887     /**
888      * SMPTE ST 2084 (Dolby Perceptual Quantizer)
889      *
890      * Transfer characteristic curve:
891      *  E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m
892      *  c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375
893      *  c2 = 32 * 2413 / 4096 = 18.8515625
894      *  c3 = 32 * 2392 / 4096 = 18.6875
895      *  m = 128 * 2523 / 4096 = 78.84375
896      *  n = 0.25 * 2610 / 4096 = 0.1593017578125
897      *      L - luminance of image 0 <= L <= 1 for HDR colorimetry.
898      *          L = 1 corresponds to 10000 cd/m2
899      *      E - corresponding electrical signal
900      */
901     TRANSFER_ST2084 = 7 << TRANSFER_SHIFT,
902
903     /**
904      * ARIB STD-B67 Hybrid Log Gamma
905      *
906      * Transfer characteristic curve:
907      *  E = r * L^0.5                 for 0 <= L <= 1
908      *    = a * ln(L - b) + c         for 1 < L
909      *  a = 0.17883277
910      *  b = 0.28466892
911      *  c = 0.55991073
912      *  r = 0.5
913      *      L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds
914      *          to reference white level of 100 cd/m2
915      *      E - corresponding electrical signal
916      */
917     TRANSFER_HLG = 8 << TRANSFER_SHIFT,
918
919     RANGE_SHIFT = 27,
920
921     /**
922      * Range aspect
923      *
924      * Defines the range of values corresponding to the unit range of 0-1.
925      * This is defined for YCbCr only, but can be expanded to RGB space.
926      */
927     RANGE_MASK = 7 << RANGE_SHIFT,  // 0x7
928
929     /**
930      * Range is unknown or are determined by the application.  Implementations
931      * shall use the following suggested ranges:
932      *
933      * All YCbCr formats: limited range.
934      * All RGB or RGBA formats (including RAW and Bayer): full range.
935      * All Y formats: full range
936      *
937      * For all other formats range is undefined, and implementations should use
938      * an appropriate range for the data represented.
939      */
940     RANGE_UNSPECIFIED = 0 << RANGE_SHIFT,
941
942     /**
943      * Full range uses all values for Y, Cb and Cr from
944      * 0 to 2^b-1, where b is the bit depth of the color format.
945      */
946     RANGE_FULL = 1 << RANGE_SHIFT,
947
948     /**
949      * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and
950      * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of
951      * the color format.
952      *
953      * E.g. For 8-bit-depth formats:
954      * Luma (Y) samples should range from 16 to 235, inclusive
955      * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
956      *
957      * For 10-bit-depth formats:
958      * Luma (Y) samples should range from 64 to 940, inclusive
959      * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
960      */
961     RANGE_LIMITED = 2 << RANGE_SHIFT,
962
963     /**
964      * Extended range is used for scRGB. Intended for use with
965      * floating point pixel formats. [0.0 - 1.0] is the standard
966      * sRGB space. Values outside the range 0.0 - 1.0 can encode
967      * color outside the sRGB gamut.
968      * Used to blend / merge multiple dataspaces on a single display.
969      */
970     RANGE_EXTENDED = 3 << RANGE_SHIFT,
971
972     /**
973      * Legacy dataspaces
974      */
975
976     /**
977      * sRGB linear encoding:
978      *
979      * The red, green, and blue components are stored in sRGB space, but
980      * are linear, not gamma-encoded.
981      * The RGB primaries and the white point are the same as BT.709.
982      *
983      * The values are encoded using the full range ([0,255] for 8-bit) for all
984      * components.
985      */
986     SRGB_LINEAR = 0x200, // deprecated, use V0_SRGB_LINEAR
987
988     V0_SRGB_LINEAR = STANDARD_BT709 | TRANSFER_LINEAR | RANGE_FULL,
989
990
991     /**
992      * scRGB linear encoding:
993      *
994      * The red, green, and blue components are stored in extended sRGB space,
995      * but are linear, not gamma-encoded.
996      * The RGB primaries and the white point are the same as BT.709.
997      *
998      * The values are floating point.
999      * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits.
1000      * Values beyond the range [0.0 - 1.0] would correspond to other colors
1001      * spaces and/or HDR content.
1002      */
1003     V0_SCRGB_LINEAR = STANDARD_BT709 | TRANSFER_LINEAR | RANGE_EXTENDED,
1004
1005
1006     /**
1007      * sRGB gamma encoding:
1008      *
1009      * The red, green and blue components are stored in sRGB space, and
1010      * converted to linear space when read, using the SRGB transfer function
1011      * for each of the R, G and B components. When written, the inverse
1012      * transformation is performed.
1013      *
1014      * The alpha component, if present, is always stored in linear space and
1015      * is left unmodified when read or written.
1016      *
1017      * Use full range and BT.709 standard.
1018      */
1019     SRGB = 0x201, // deprecated, use V0_SRGB
1020
1021     V0_SRGB = STANDARD_BT709 | TRANSFER_SRGB | RANGE_FULL,
1022
1023
1024     /**
1025      * scRGB:
1026      *
1027      * The red, green, and blue components are stored in extended sRGB space,
1028      * but are linear, not gamma-encoded.
1029      * The RGB primaries and the white point are the same as BT.709.
1030      *
1031      * The values are floating point.
1032      * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits.
1033      * Values beyond the range [0.0 - 1.0] would correspond to other colors
1034      * spaces and/or HDR content.
1035      */
1036     V0_SCRGB = STANDARD_BT709 | TRANSFER_SRGB | RANGE_EXTENDED,
1037
1038     /**
1039      * YCbCr Colorspaces
1040      * -----------------
1041      *
1042      * Primaries are given using (x,y) coordinates in the CIE 1931 definition
1043      * of x and y specified by ISO 11664-1.
1044      *
1045      * Transfer characteristics are the opto-electronic transfer characteristic
1046      * at the source as a function of linear optical intensity (luminance).
1047      */
1048
1049     /**
1050      * JPEG File Interchange Format (JFIF)
1051      *
1052      * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
1053      *
1054      * Use full range, BT.601 transfer and BT.601_625 standard.
1055      */
1056     JFIF = 0x101, // deprecated, use V0_JFIF
1057
1058     V0_JFIF = STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_FULL,
1059
1060     /**
1061      * ITU-R Recommendation 601 (BT.601) - 625-line
1062      *
1063      * Standard-definition television, 625 Lines (PAL)
1064      *
1065      * Use limited range, BT.601 transfer and BT.601_625 standard.
1066      */
1067     BT601_625 = 0x102, // deprecated, use V0_BT601_625
1068
1069     V0_BT601_625 = STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
1070
1071
1072     /**
1073      * ITU-R Recommendation 601 (BT.601) - 525-line
1074      *
1075      * Standard-definition television, 525 Lines (NTSC)
1076      *
1077      * Use limited range, BT.601 transfer and BT.601_525 standard.
1078      */
1079     BT601_525 = 0x103, // deprecated, use V0_BT601_525
1080
1081     V0_BT601_525 = STANDARD_BT601_525 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
1082
1083     /**
1084      * ITU-R Recommendation 709 (BT.709)
1085      *
1086      * High-definition television
1087      *
1088      * Use limited range, BT.709 transfer and BT.709 standard.
1089      */
1090     BT709 = 0x104, // deprecated, use V0_BT709
1091
1092     V0_BT709 = STANDARD_BT709 | TRANSFER_SMPTE_170M | RANGE_LIMITED,
1093
1094
1095     /**
1096      * SMPTE EG 432-1 and SMPTE RP 431-2.
1097      *
1098      * Digital Cinema DCI-P3
1099      *
1100      * Use full range, linear transfer and D65 DCI-P3 standard
1101      */
1102     DCI_P3_LINEAR = STANDARD_DCI_P3 | TRANSFER_LINEAR | RANGE_FULL,
1103
1104
1105     /**
1106      * SMPTE EG 432-1 and SMPTE RP 431-2.
1107      *
1108      * Digital Cinema DCI-P3
1109      *
1110      * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard
1111      * Note: Application is responsible for gamma encoding the data as
1112      * a 2.6 gamma encoding is not supported in HW.
1113      */
1114     DCI_P3 = STANDARD_DCI_P3 | TRANSFER_GAMMA2_6 | RANGE_FULL,
1115
1116
1117     /**
1118      * Display P3
1119      *
1120      * Display P3 uses same primaries and white-point as DCI-P3
1121      * linear transfer function makes this the same as DCI_P3_LINEAR.
1122      */
1123     DISPLAY_P3_LINEAR = STANDARD_DCI_P3 | TRANSFER_LINEAR | RANGE_FULL,
1124
1125
1126     /**
1127      * Display P3
1128      *
1129      * Use same primaries and white-point as DCI-P3
1130      * but sRGB transfer function.
1131      */
1132     DISPLAY_P3 = STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_FULL,
1133
1134
1135     /**
1136      * Adobe RGB
1137      *
1138      * Use full range, gamma 2.2 transfer and Adobe RGB primaries
1139      * Note: Application is responsible for gamma encoding the data as
1140      * a 2.2 gamma encoding is not supported in HW.
1141      */
1142     ADOBE_RGB = STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2 | RANGE_FULL,
1143
1144
1145     /**
1146      * ITU-R Recommendation 2020 (BT.2020)
1147      *
1148      * Ultra High-definition television
1149      *
1150      * Use full range, linear transfer and BT2020 standard
1151      */
1152     BT2020_LINEAR = STANDARD_BT2020 | TRANSFER_LINEAR | RANGE_FULL,
1153
1154
1155     /**
1156      * ITU-R Recommendation 2020 (BT.2020)
1157      *
1158      * Ultra High-definition television
1159      *
1160      * Use full range, BT.709 transfer and BT2020 standard
1161      */
1162     BT2020 = STANDARD_BT2020 | TRANSFER_SMPTE_170M | RANGE_FULL,
1163
1164     /**
1165      * ITU-R Recommendation 2020 (BT.2020)
1166      *
1167      * Ultra High-definition television
1168      *
1169      * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard
1170      */
1171     BT2020_PQ = STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL,
1172
1173
1174     /**
1175      * Data spaces for non-color formats
1176      */
1177
1178     /**
1179      * The buffer contains depth ranging measurements from a depth camera.
1180      * This value is valid with formats:
1181      *    HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement
1182      *       and an associated confidence value. The 3 MSBs of the sample make
1183      *       up the confidence value, and the low 13 LSBs of the sample make up
1184      *       the depth measurement.
1185      *       For the confidence section, 0 means 100% confidence, 1 means 0%
1186      *       confidence. The mapping to a linear float confidence value between
1187      *       0.f and 1.f can be obtained with
1188      *         float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f;
1189      *       The depth measurement can be extracted simply with
1190      *         uint16_t range = (depthSample & 0x1FFF);
1191      *    HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as
1192      *       a variable-length float (x,y,z, confidence) coordinate point list.
1193      *       The point cloud will be represented with the android_depth_points
1194      *       structure.
1195      */
1196     DEPTH = 0x1000,
1197
1198
1199     /**
1200      * The buffer contains sensor events from sensor direct report.
1201      * This value is valid with formats:
1202      *    HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms
1203      *       a lock free queue. Format of sensor event structure is specified
1204      *       in Sensors HAL.
1205      */
1206     SENSOR = 0x1001
1207 };
1208
1209 /**
1210  * Color modes that may be supported by a display.
1211  *
1212  * Definitions:
1213  * Rendering intent generally defines the goal in mapping a source (input)
1214  * color to a destination device color for a given color mode.
1215  *
1216  *  It is important to keep in mind three cases where mapping may be applied:
1217  *  1. The source gamut is much smaller than the destination (display) gamut
1218  *  2. The source gamut is much larger than the destination gamut (this will
1219  *  ordinarily be handled using colorimetric rendering, below)
1220  *  3. The source and destination gamuts are roughly equal, although not
1221  *  completely overlapping
1222  *  Also, a common requirement for mappings is that skin tones should be
1223  *  preserved, or at least remain natural in appearance.
1224  *
1225  *  Colorimetric Rendering Intent (All cases):
1226  *  Colorimetric indicates that colors should be preserved. In the case
1227  *  that the source gamut lies wholly within the destination gamut or is
1228  *  about the same (#1, #3), this will simply mean that no manipulations
1229  *  (no saturation boost, for example) are applied. In the case where some
1230  *  source colors lie outside the destination gamut (#2, #3), those will
1231  *  need to be mapped to colors that are within the destination gamut,
1232  *  while the already in-gamut colors remain unchanged.
1233  *
1234  *  Non-colorimetric transforms can take many forms. There are no hard
1235  *  rules and it's left to the implementation to define.
1236  *  Two common intents are described below.
1237  *
1238  *  Stretched-Gamut Enhancement Intent (Source < Destination):
1239  *  When the destination gamut is much larger than the source gamut (#1), the
1240  *  source primaries may be redefined to reflect the full extent of the
1241  *  destination space, or to reflect an intermediate gamut.
1242  *  Skin-tone preservation would likely be applied. An example might be sRGB
1243  *  input displayed on a DCI-P3 capable device, with skin-tone preservation.
1244  *
1245  *  Within-Gamut Enhancement Intent (Source >= Destination):
1246  *  When the device (destination) gamut is not larger than the source gamut
1247  *  (#2 or #3), but the appearance of a larger gamut is desired, techniques
1248  *  such as saturation boost may be applied to the source colors. Skin-tone
1249  *  preservation may be applied. There is no unique method for within-gamut
1250  *  enhancement; it would be defined within a flexible color mode.
1251  *
1252  */
1253 @export(name="android_color_mode_t", value_prefix="HAL_COLOR_MODE_")
1254 enum ColorMode : int32_t {
1255   /**
1256    * DEFAULT is the "native" gamut of the display.
1257    * White Point: Vendor/OEM defined
1258    * Panel Gamma: Vendor/OEM defined (typically 2.2)
1259    * Rendering Intent: Vendor/OEM defined (typically 'enhanced')
1260    */
1261   NATIVE = 0,
1262
1263   /**
1264    * STANDARD_BT601_625 corresponds with display
1265    * settings that implement the ITU-R Recommendation BT.601
1266    * or Rec 601. Using 625 line version
1267    * Rendering Intent: Colorimetric
1268    * Primaries:
1269    *                  x       y
1270    *  green           0.290   0.600
1271    *  blue            0.150   0.060
1272    *  red             0.640   0.330
1273    *  white (D65)     0.3127  0.3290
1274    *
1275    *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
1276    *  for RGB conversion from the one purely determined by the primaries
1277    *  to minimize the color shift into RGB space that uses BT.709
1278    *  primaries.
1279    *
1280    * Gamma Correction (GC):
1281    *
1282    *  if Vlinear < 0.018
1283    *    Vnonlinear = 4.500 * Vlinear
1284    *  else
1285    *    Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1286    */
1287   STANDARD_BT601_625 = 1,
1288
1289   /**
1290    * Primaries:
1291    *                  x       y
1292    *  green           0.290   0.600
1293    *  blue            0.150   0.060
1294    *  red             0.640   0.330
1295    *  white (D65)     0.3127  0.3290
1296    *
1297    *  Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
1298    *  for RGB conversion.
1299    *
1300    * Gamma Correction (GC):
1301    *
1302    *  if Vlinear < 0.018
1303    *    Vnonlinear = 4.500 * Vlinear
1304    *  else
1305    *    Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1306    */
1307   STANDARD_BT601_625_UNADJUSTED = 2,
1308
1309   /**
1310    * Primaries:
1311    *                  x       y
1312    *  green           0.310   0.595
1313    *  blue            0.155   0.070
1314    *  red             0.630   0.340
1315    *  white (D65)     0.3127  0.3290
1316    *
1317    *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
1318    *  for RGB conversion from the one purely determined by the primaries
1319    *  to minimize the color shift into RGB space that uses BT.709
1320    *  primaries.
1321    *
1322    * Gamma Correction (GC):
1323    *
1324    *  if Vlinear < 0.018
1325    *    Vnonlinear = 4.500 * Vlinear
1326    *  else
1327    *    Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1328    */
1329   STANDARD_BT601_525 = 3,
1330
1331   /**
1332    * Primaries:
1333    *                  x       y
1334    *  green           0.310   0.595
1335    *  blue            0.155   0.070
1336    *  red             0.630   0.340
1337    *  white (D65)     0.3127  0.3290
1338    *
1339    *  Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
1340    *  for RGB conversion (as in SMPTE 240M).
1341    *
1342    * Gamma Correction (GC):
1343    *
1344    *  if Vlinear < 0.018
1345    *    Vnonlinear = 4.500 * Vlinear
1346    *  else
1347    *    Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099
1348    */
1349   STANDARD_BT601_525_UNADJUSTED = 4,
1350
1351   /**
1352    * REC709 corresponds with display settings that implement
1353    * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television.
1354    * Rendering Intent: Colorimetric
1355    * Primaries:
1356    *                  x       y
1357    *  green           0.300   0.600
1358    *  blue            0.150   0.060
1359    *  red             0.640   0.330
1360    *  white (D65)     0.3127  0.3290
1361    *
1362    * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized
1363    * (with [0 to 1] range) value of R, G, or B.
1364    *
1365    *  if Vnonlinear < 0.081
1366    *    Vlinear = Vnonlinear / 4.5
1367    *  else
1368    *    Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45)
1369    *
1370    * HDTV REC709 Gamma Correction (GC):
1371    *
1372    *  if Vlinear < 0.018
1373    *    Vnonlinear = 4.5 * Vlinear
1374    *  else
1375    *    Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099
1376    */
1377   STANDARD_BT709 = 5,
1378
1379   /**
1380    * DCI_P3 corresponds with display settings that implement
1381    * SMPTE EG 432-1 and SMPTE RP 431-2
1382    * Rendering Intent: Colorimetric
1383    * Primaries:
1384    *                  x       y
1385    *  green           0.265   0.690
1386    *  blue            0.150   0.060
1387    *  red             0.680   0.320
1388    *  white (D65)     0.3127  0.3290
1389    *
1390    * Gamma: 2.6
1391    */
1392   DCI_P3 = 6,
1393
1394   /**
1395    * SRGB corresponds with display settings that implement
1396    * the sRGB color space. Uses the same primaries as ITU-R Recommendation
1397    * BT.709
1398    * Rendering Intent: Colorimetric
1399    * Primaries:
1400    *                  x       y
1401    *  green           0.300   0.600
1402    *  blue            0.150   0.060
1403    *  red             0.640   0.330
1404    *  white (D65)     0.3127  0.3290
1405    *
1406    * PC/Internet (sRGB) Inverse Gamma Correction (IGC):
1407    *
1408    *  if Vnonlinear ≤ 0.03928
1409    *    Vlinear = Vnonlinear / 12.92
1410    *  else
1411    *    Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4
1412    *
1413    * PC/Internet (sRGB) Gamma Correction (GC):
1414    *
1415    *  if Vlinear ≤ 0.0031308
1416    *    Vnonlinear = 12.92 * Vlinear
1417    *  else
1418    *    Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055
1419    */
1420   SRGB = 7,
1421
1422   /**
1423    * ADOBE_RGB corresponds with the RGB color space developed
1424    * by Adobe Systems, Inc. in 1998.
1425    * Rendering Intent: Colorimetric
1426    * Primaries:
1427    *                  x       y
1428    *  green           0.210   0.710
1429    *  blue            0.150   0.060
1430    *  red             0.640   0.330
1431    *  white (D65)     0.3127  0.3290
1432    *
1433    * Gamma: 2.2
1434    */
1435   ADOBE_RGB = 8,
1436
1437   /**
1438    * DISPLAY_P3 is a color space that uses the DCI_P3 primaries,
1439    * the D65 white point and the SRGB transfer functions.
1440    * Rendering Intent: Colorimetric
1441    * Primaries:
1442    *                  x       y
1443    *  green           0.265   0.690
1444    *  blue            0.150   0.060
1445    *  red             0.680   0.320
1446    *  white (D65)     0.3127  0.3290
1447    *
1448    * PC/Internet (sRGB) Gamma Correction (GC):
1449    *
1450    *  if Vlinear ≤ 0.0030186
1451    *    Vnonlinear = 12.92 * Vlinear
1452    *  else
1453    *    Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055
1454    *
1455    * Note: In most cases sRGB transfer function will be fine.
1456    */
1457   DISPLAY_P3 = 9
1458 };
1459
1460 /**
1461  * Color transforms that may be applied by hardware composer to the whole
1462  * display.
1463  */
1464 @export(name="android_color_transform_t", value_prefix="HAL_COLOR_TRANSFORM_")
1465 enum ColorTransform : int32_t {
1466     /** Applies no transform to the output color */
1467     IDENTITY = 0,
1468
1469     /** Applies an arbitrary transform defined by a 4x4 affine matrix */
1470     ARBITRARY_MATRIX = 1,
1471
1472     /**
1473      * Applies a transform that inverts the value or luminance of the color, but
1474      * does not modify hue or saturation */
1475     VALUE_INVERSE = 2,
1476
1477     /** Applies a transform that maps all colors to shades of gray */
1478     GRAYSCALE = 3,
1479
1480     /** Applies a transform which corrects for protanopic color blindness */
1481     CORRECT_PROTANOPIA = 4,
1482
1483     /** Applies a transform which corrects for deuteranopic color blindness */
1484     CORRECT_DEUTERANOPIA = 5,
1485
1486     /** Applies a transform which corrects for tritanopic color blindness */
1487     CORRECT_TRITANOPIA = 6
1488 };
1489
1490 /**
1491  * Supported HDR formats. Must be kept in sync with equivalents in Display.java.
1492  */
1493 @export(name="android_hdr_t", value_prefix="HAL_HDR_")
1494 enum Hdr : int32_t {
1495     /** Device supports Dolby Vision HDR */
1496     DOLBY_VISION = 1,
1497
1498     /** Device supports HDR10 */
1499     HDR10 = 2,
1500
1501     /** Device supports hybrid log-gamma HDR */
1502     HLG = 3
1503 };