1 /* Copyright (c) 2014, The Linux Foundataion. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 
30 #ifndef __QCAMERA3VENDORTAGS_H__
31 #define __QCAMERA3VENDORTAGS_H__
32 
33 namespace qcamera {
34 
35 enum qcamera3_ext_section {
36     QCAMERA3_PRIVATEDATA = VENDOR_SECTION,
37     QCAMERA3_CDS,
38     QCAMERA3_OPAQUE_RAW,
39     QCAMERA3_CROP,
40     QCAMERA3_TUNING_META_DATA,
41     QCAMERA3_SECTIONS_END
42 };
43 
44 enum qcamera3_ext_section_ranges {
45     QCAMERA3_PRIVATEDATA_START = QCAMERA3_PRIVATEDATA << 16,
46     QCAMERA3_CDS_START = QCAMERA3_CDS << 16,
47     QCAMERA3_OPAQUE_RAW_START = QCAMERA3_OPAQUE_RAW << 16,
48     QCAMERA3_CROP_START = QCAMERA3_CROP << 16,
49     QCAMERA3_TUNING_META_DATA_START = QCAMERA3_TUNING_META_DATA << 16,
50 };
51 
52 enum qcamera3_ext_tags {
53     QCAMERA3_PRIVATEDATA_REPROCESS = QCAMERA3_PRIVATEDATA_START,
54     QCAMERA3_PRIVATEDATA_END,
55     QCAMERA3_CDS_MODE = QCAMERA3_CDS_START,
56     QCAMERA3_CDS_END,
57 
58     //Property Name:  org.codeaurora.qcamera3.opaque_raw.opaque_raw_strides
59     //
60     //Type: int32 * n * 3 [public]
61     //
62     //Description: Distance in bytes from the beginning of one row of opaque
63     //raw image data to the beginning of next row.
64     //
65     //Details: The strides are listed as (raw_width, raw_height, stride)
66     //triplets. For each supported raw size, there will be a stride associated
67     //with it.
68     QCAMERA3_OPAQUE_RAW_STRIDES = QCAMERA3_OPAQUE_RAW_START,
69 
70     //Property Name: org.codeaurora.qcamera3.opaque_raw.opaque_raw_format
71     //
72     //Type: byte(enum) [public]
73     //  * LEGACY - The legacy raw format where 8, 10, or 12-bit
74     //    raw data is packed into a 64-bit word.
75     //  * MIPI - raw format matching the data packing described
76     //    in MIPI CSI-2 specification. In memory, the data
77     //    is constructed by packing sequentially received pixels
78     //    into least significant parts of the words first.
79     //    Within each pixel, the least significant bits are also
80     //    placed towards the least significant part of the word.
81     //
82     //Details: Lay out of opaque raw data in memory is decided by two factors:
83     //         opaque_raw_format and bit depth (implied by whiteLevel). Below
84     //         list illustrates their relationship:
85     //  LEGACY8:  P7(7:0) P6(7:0) P5(7:0) P4(7:0) P3(7:0) P2(7:0) P1(7:0) P0(7:0)
86     //            8 pixels occupy 8 bytes, no padding needed
87     //            min_stride = CEILING8(raw_width)
88     // LEGACY10:  0000 P5(9:0) P4(9:0) P3(9:0) P2(9:0) P1(9:0) P0(9:0)
89     //            6 pixels occupy 8 bytes, 4 bits padding at MSB
90     //            min_stride = (raw_width+5)/6 * 8
91     // LEGACY12:  0000 P4(11:0) P3(11:0) P2(11:0) P1(11:0) P0(11:0)
92     //            5 pixels occupy 8 bytes, 4 bits padding at MSB
93     //            min_stride = (raw_width+4)/5 * 8
94     //    MIPI8:  P0(7:0)
95     //            1 pixel occupy 1 byte, no padding needed
96     //            min_stride = raw_width
97     //   MIPI10:  P3(1:0) P2(1:0) P1(1:0) P0(1:0) P3(9:2) P2(9:2) P1(9:2) P0(9:2)
98     //            4 pixels occupy 5 bytes, no padding needed
99     //            min_stride = (raw_width+3)/4 * 5
100     //   MIPI12:  P1(3:0) P0(3:0) P1(11:4) P0(11:4)
101     //            2 pixels occupy 3 bytes, no padding needed
102     //            min_stride = (raw_width+1)/2 * 3
103     //Note that opaque_raw_stride needs to be at least the required minimum
104     //stride from the table above. ISP hardware may need more generous stride
105     //setting. For example, for LEGACY8, the actual stride may be
106     //CEILING16(raw_width) due to bus burst length requirement.
107     QCAMERA3_OPAQUE_RAW_FORMAT,
108     QCAMERA3_OPAQUE_RAW_END,
109 
110     QCAMERA3_CROP_COUNT_REPROCESS = QCAMERA3_CROP_START,
111     QCAMERA3_CROP_REPROCESS,
112     QCAMERA3_CROP_STREAM_ID_REPROCESS,
113     QCAMERA3_CROP_END,
114 
115     QCAMERA3_TUNING_META_DATA_BLOB = QCAMERA3_TUNING_META_DATA_START,
116     QCAMERA3_TUNING_META_DATA_END
117 };
118 
119 // QCAMERA3_OPAQUE_RAW_FORMAT
120 typedef enum qcamera3_ext_opaque_raw_format {
121     QCAMERA3_OPAQUE_RAW_FORMAT_LEGACY,
122     QCAMERA3_OPAQUE_RAW_FORMAT_MIPI
123 } qcamera3_ext_opaque_raw_format_t;
124 
125 class QCamera3VendorTags {
126 
127 public:
128     static void get_vendor_tag_ops(vendor_tag_ops_t* ops);
129     static int get_tag_count(
130             const vendor_tag_ops_t *ops);
131     static void get_all_tags(
132             const vendor_tag_ops_t *ops,
133             uint32_t *tag_array);
134     static const char* get_section_name(
135             const vendor_tag_ops_t *ops,
136             uint32_t tag);
137     static const char* get_tag_name(
138             const vendor_tag_ops_t *ops,
139             uint32_t tag);
140     static int get_tag_type(
141             const vendor_tag_ops_t *ops,
142             uint32_t tag);
143 
144     static const vendor_tag_ops_t *Ops;
145 };
146 
147 }; // namespace qcamera
148 
149 #endif /* __QCAMERA3VENDORTAGS_H__ */
150