• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <common/bk_err.h>
18 #include <bk_list.h>
19 
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define PIXEL_240 	(240)
26 #define PIXEL_272 	(272)
27 #define PIXEL_320 	(320)
28 #define PIXEL_480 	(480)
29 #define PIXEL_600 	(600)
30 #define PIXEL_640 	(640)
31 #define PIXEL_720 	(720)
32 #define PIXEL_800 	(800)
33 #define PIXEL_1024 (1024)
34 #define PIXEL_1200 (1200)
35 #define PIXEL_1280 (1280)
36 #define PIXEL_1600 (1600)
37 
38 
39 typedef enum
40 {
41 	PPI_DEFAULT     = 0,
42 	PPI_320X240     = (PIXEL_320 << 16) | PIXEL_240,
43 	PPI_320X480     = (PIXEL_320 << 16) | PIXEL_480,
44 	PPI_480X272     = (PIXEL_480 << 16) | PIXEL_272,
45 	PPI_480X320     = (PIXEL_480 << 16) | PIXEL_320,
46 	PPI_640X480     = (PIXEL_640 << 16) | PIXEL_480,
47 	PPI_480X800 	= (PIXEL_480 << 16) | PIXEL_800,
48 	PPI_800X480 	= (PIXEL_800 << 16) | PIXEL_480,
49 	PPI_800X600     = (PIXEL_800 << 16) | PIXEL_640,
50 	PPI_1024X600    = (PIXEL_1024 << 16) | PIXEL_600,
51 	PPI_1280X720    = (PIXEL_1280 << 16) | PIXEL_720,
52 	PPI_1600X1200   = (PIXEL_1600 << 16) | PIXEL_1200,
53 } media_ppi_t;
54 
55 typedef enum
56 {
57 	PPI_CAP_UNKNOW 		= 0,
58 	PPI_CAP_320X240     = (1 << 0), /**< 320 * 240 */
59 	PPI_CAP_320X480     = (1 << 1), /**< 320 * 480 */
60 	PPI_CAP_480X272     = (1 << 2), /**< 480 * 272 */
61 	PPI_CAP_480X320     = (1 << 3), /**< 480 * 320 */
62 	PPI_CAP_640X480     = (1 << 4), /**< 640 * 480 */
63 	PPI_CAP_480X800     = (1 << 5), /**< 480 * 800 */
64 	PPI_CAP_800X480     = (1 << 6), /**< 800 * 480 */
65 	PPI_CAP_800X600     = (1 << 7), /**< 800 * 600 */
66 	PPI_CAP_1024X600    = (1 << 8), /**< 1024 * 600 */
67 	PPI_CAP_1280X720    = (1 << 9), /**< 1280 * 720 */
68 	PPI_CAP_1600X1200   = (1 << 10), /**< 1600 * 1200 */
69 } media_ppi_cap_t;
70 
71 
72 typedef enum
73 {
74 	STATE_INVALID = 0,
75 	STATE_ALLOCED,
76 	STATE_FRAMED,
77 } frame_state_t;
78 
79 typedef enum
80 {
81 	FRAME_DISPLAY,
82 	FRAME_JPEG,
83 } frame_type_t;
84 
85 typedef struct
86 {
87 	LIST_HEADER_T list;
88 	frame_state_t state;
89 	frame_type_t type;
90 	uint8_t id;
91 	uint8_t lock;
92 	uint8_t *frame;
93 	uint32_t length;
94 	uint32_t size;
95 	uint32_t sequence;
96 } frame_buffer_t;
97 
98 typedef enum
99 {
100 	UNKNOW_CAMERA,
101 	DVP_CAMERA,
102 	UVC_CAMERA,
103 } camera_type_t;
104 
105 typedef struct
106 {
107 	uint16_t isr_jpeg;
108 	uint16_t isr_decoder;
109 	uint16_t err_dec;
110 	uint16_t isr_lcd;
111 	uint16_t fps_lcd;
112 	uint16_t fps_wifi;
113 } media_debug_t;
114 
ppi_to_pixel_x(media_ppi_t ppi)115 static inline uint16_t ppi_to_pixel_x(media_ppi_t ppi)
116 {
117 	return ppi >> 16;
118 }
119 
ppi_to_pixel_y(media_ppi_t ppi)120 static inline uint16_t ppi_to_pixel_y(media_ppi_t ppi)
121 {
122 	return ppi & 0xFFFF;
123 }
124 
ppi_to_pixel_x_block(media_ppi_t ppi)125 static inline uint16_t ppi_to_pixel_x_block(media_ppi_t ppi)
126 {
127 	return (ppi >> 16) / 8;
128 }
129 
ppi_to_pixel_y_block(media_ppi_t ppi)130 static inline uint16_t ppi_to_pixel_y_block(media_ppi_t ppi)
131 {
132 	return (ppi & 0xFFFF) / 8;
133 }
134 
135 
pixel_ppi_to_cap(media_ppi_t ppi)136 static inline media_ppi_cap_t pixel_ppi_to_cap(media_ppi_t ppi)
137 {
138 	media_ppi_cap_t cap = PPI_CAP_UNKNOW;
139 
140 	switch (ppi)
141 	{
142 		case PPI_320X240:
143 			cap = PPI_CAP_320X240;
144 			break;
145 
146 		case PPI_320X480:
147 			cap = PPI_CAP_320X480;
148 			break;
149 
150 		case PPI_480X272:
151 			cap = PPI_CAP_480X272;
152 			break;
153 
154 		case PPI_480X320:
155 			cap = PPI_CAP_480X320;
156 			break;
157 
158 		case PPI_640X480:
159 			cap = PPI_CAP_640X480;
160 			break;
161 
162 		case PPI_480X800:
163 			cap = PPI_CAP_480X800;
164 			break;
165 
166 		case PPI_800X480:
167 			cap = PPI_CAP_800X480;
168 			break;
169 
170 		case PPI_800X600:
171 			cap = PPI_CAP_800X600;
172 			break;
173 
174 		case PPI_1024X600:
175 			cap = PPI_CAP_1024X600;
176 			break;
177 
178 		case PPI_1280X720:
179 			cap = PPI_CAP_1280X720;
180 			break;
181 
182 		case PPI_1600X1200:
183 			cap = PPI_CAP_1600X1200;
184 			break;
185 
186 		case PPI_DEFAULT:
187 		default:
188 			break;
189 	}
190 
191 	return cap;
192 }
193 
get_ppi_size(media_ppi_t ppi)194 static inline uint32_t get_ppi_size(media_ppi_t ppi)
195 {
196 	return (ppi >> 16) * (ppi & 0xFFFF) * 2;
197 }
198 
199 
200 /*
201  * @}
202  */
203 
204 #ifdef __cplusplus
205 }
206 #endif
207