cam_hal.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. // Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
  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. #include <stdio.h>
  15. #include <string.h>
  16. #include "esp_heap_caps.h"
  17. #include "ll_cam.h"
  18. #include "cam_hal.h"
  19. #if (ESP_IDF_VERSION_MAJOR == 3) && (ESP_IDF_VERSION_MINOR == 3)
  20. #include "rom/ets_sys.h"
  21. #else
  22. #if CONFIG_IDF_TARGET_ESP32
  23. #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0
  24. #elif CONFIG_IDF_TARGET_ESP32S2
  25. #include "esp32s2/rom/ets_sys.h"
  26. #elif CONFIG_IDF_TARGET_ESP32S3
  27. #include "esp32s3/rom/ets_sys.h"
  28. #endif
  29. #endif // ESP_IDF_VERSION_MAJOR
  30. #define ESP_CAMERA_ETS_PRINTF ets_printf
  31. static const char *TAG = "cam_hal";
  32. static cam_obj_t *cam_obj = NULL;
  33. static const uint32_t JPEG_SOI_MARKER = 0xFFD8FF; // written in little-endian for esp32
  34. static const uint16_t JPEG_EOI_MARKER = 0xD9FF; // written in little-endian for esp32
  35. static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length)
  36. {
  37. uint32_t sig = *((uint32_t *)inbuf) & 0xFFFFFF;
  38. if(sig != JPEG_SOI_MARKER) {
  39. for (uint32_t i = 0; i < length; i++) {
  40. sig = *((uint32_t *)(&inbuf[i])) & 0xFFFFFF;
  41. if (sig == JPEG_SOI_MARKER) {
  42. ESP_LOGW(TAG, "SOI: %d", i);
  43. return i;
  44. }
  45. }
  46. ESP_LOGW(TAG, "NO-SOI");
  47. return -1;
  48. }
  49. return 0;
  50. }
  51. static int cam_verify_jpeg_eoi(const uint8_t *inbuf, uint32_t length)
  52. {
  53. int offset = -1;
  54. uint8_t *dptr = (uint8_t *)inbuf + length - 2;
  55. while (dptr > inbuf) {
  56. uint16_t sig = *((uint16_t *)dptr);
  57. if (JPEG_EOI_MARKER == sig) {
  58. offset = dptr - inbuf;
  59. //ESP_LOGW(TAG, "EOI: %d", length - (offset + 2));
  60. return offset;
  61. }
  62. dptr--;
  63. }
  64. return -1;
  65. }
  66. static bool cam_get_next_frame(int * frame_pos)
  67. {
  68. if(!cam_obj->frames[*frame_pos].en){
  69. for (int x = 0; x < cam_obj->frame_cnt; x++) {
  70. if (cam_obj->frames[x].en) {
  71. *frame_pos = x;
  72. return true;
  73. }
  74. }
  75. } else {
  76. return true;
  77. }
  78. return false;
  79. }
  80. static bool cam_start_frame(int * frame_pos)
  81. {
  82. if (cam_get_next_frame(frame_pos)) {
  83. if(ll_cam_start(cam_obj, *frame_pos)){
  84. // Vsync the frame manually
  85. ll_cam_do_vsync(cam_obj);
  86. uint64_t us = (uint64_t)esp_timer_get_time();
  87. cam_obj->frames[*frame_pos].fb.timestamp.tv_sec = us / 1000000UL;
  88. cam_obj->frames[*frame_pos].fb.timestamp.tv_usec = us % 1000000UL;
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. void IRAM_ATTR ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType_t * HPTaskAwoken)
  95. {
  96. if (xQueueSendFromISR(cam->event_queue, (void *)&cam_event, HPTaskAwoken) != pdTRUE) {
  97. ll_cam_stop(cam);
  98. cam->state = CAM_STATE_IDLE;
  99. ESP_CAMERA_ETS_PRINTF(DRAM_STR("cam_hal: EV-%s-OVF\r\n"), cam_event==CAM_IN_SUC_EOF_EVENT ? DRAM_STR("EOF") : DRAM_STR("VSYNC"));
  100. }
  101. }
  102. //Copy fram from DMA dma_buffer to fram dma_buffer
  103. static void cam_task(void *arg)
  104. {
  105. int cnt = 0;
  106. int frame_pos = 0;
  107. cam_obj->state = CAM_STATE_IDLE;
  108. cam_event_t cam_event = 0;
  109. xQueueReset(cam_obj->event_queue);
  110. while (1) {
  111. xQueueReceive(cam_obj->event_queue, (void *)&cam_event, portMAX_DELAY);
  112. DBG_PIN_SET(1);
  113. switch (cam_obj->state) {
  114. case CAM_STATE_IDLE: {
  115. if (cam_event == CAM_VSYNC_EVENT) {
  116. //DBG_PIN_SET(1);
  117. if(cam_start_frame(&frame_pos)){
  118. cam_obj->frames[frame_pos].fb.len = 0;
  119. cam_obj->state = CAM_STATE_READ_BUF;
  120. }
  121. cnt = 0;
  122. }
  123. }
  124. break;
  125. case CAM_STATE_READ_BUF: {
  126. camera_fb_t * frame_buffer_event = &cam_obj->frames[frame_pos].fb;
  127. size_t pixels_per_dma = (cam_obj->dma_half_buffer_size * cam_obj->fb_bytes_per_pixel) / (cam_obj->dma_bytes_per_item * cam_obj->in_bytes_per_pixel);
  128. if (cam_event == CAM_IN_SUC_EOF_EVENT) {
  129. if(!cam_obj->psram_mode){
  130. if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) {
  131. ESP_LOGW(TAG, "FB-OVF");
  132. ll_cam_stop(cam_obj);
  133. DBG_PIN_SET(0);
  134. continue;
  135. }
  136. frame_buffer_event->len += ll_cam_memcpy(cam_obj,
  137. &frame_buffer_event->buf[frame_buffer_event->len],
  138. &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size],
  139. cam_obj->dma_half_buffer_size);
  140. }
  141. //Check for JPEG SOI in the first buffer. stop if not found
  142. if (cam_obj->jpeg_mode && cnt == 0 && cam_verify_jpeg_soi(frame_buffer_event->buf, frame_buffer_event->len) != 0) {
  143. ll_cam_stop(cam_obj);
  144. cam_obj->state = CAM_STATE_IDLE;
  145. }
  146. cnt++;
  147. } else if (cam_event == CAM_VSYNC_EVENT) {
  148. //DBG_PIN_SET(1);
  149. ll_cam_stop(cam_obj);
  150. if (cnt || !cam_obj->jpeg_mode || cam_obj->psram_mode) {
  151. if (cam_obj->jpeg_mode) {
  152. if (!cam_obj->psram_mode) {
  153. if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) {
  154. ESP_LOGW(TAG, "FB-OVF");
  155. cnt--;
  156. } else {
  157. frame_buffer_event->len += ll_cam_memcpy(cam_obj,
  158. &frame_buffer_event->buf[frame_buffer_event->len],
  159. &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size],
  160. cam_obj->dma_half_buffer_size);
  161. }
  162. }
  163. cnt++;
  164. }
  165. cam_obj->frames[frame_pos].en = 0;
  166. if (cam_obj->psram_mode) {
  167. if (cam_obj->jpeg_mode) {
  168. frame_buffer_event->len = cnt * cam_obj->dma_half_buffer_size;
  169. } else {
  170. frame_buffer_event->len = cam_obj->recv_size;
  171. }
  172. } else if (!cam_obj->jpeg_mode) {
  173. if (frame_buffer_event->len != cam_obj->fb_size) {
  174. cam_obj->frames[frame_pos].en = 1;
  175. ESP_LOGE(TAG, "FB-SIZE: %u != %u", frame_buffer_event->len, cam_obj->fb_size);
  176. }
  177. }
  178. //send frame
  179. if(!cam_obj->frames[frame_pos].en && xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) {
  180. //pop frame buffer from the queue
  181. camera_fb_t * fb2 = NULL;
  182. if(xQueueReceive(cam_obj->frame_buffer_queue, &fb2, 0) == pdTRUE) {
  183. //push the new frame to the end of the queue
  184. if (xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) {
  185. cam_obj->frames[frame_pos].en = 1;
  186. ESP_LOGE(TAG, "FBQ-SND");
  187. }
  188. //free the popped buffer
  189. cam_give(fb2);
  190. } else {
  191. //queue is full and we could not pop a frame from it
  192. cam_obj->frames[frame_pos].en = 1;
  193. ESP_LOGE(TAG, "FBQ-RCV");
  194. }
  195. }
  196. }
  197. if(!cam_start_frame(&frame_pos)){
  198. cam_obj->state = CAM_STATE_IDLE;
  199. } else {
  200. cam_obj->frames[frame_pos].fb.len = 0;
  201. }
  202. cnt = 0;
  203. }
  204. }
  205. break;
  206. }
  207. DBG_PIN_SET(0);
  208. }
  209. }
  210. static lldesc_t * allocate_dma_descriptors(uint32_t count, uint16_t size, uint8_t * buffer)
  211. {
  212. lldesc_t *dma = (lldesc_t *)heap_caps_malloc(count * sizeof(lldesc_t), MALLOC_CAP_DMA);
  213. if (dma == NULL) {
  214. return dma;
  215. }
  216. for (int x = 0; x < count; x++) {
  217. dma[x].size = size;
  218. dma[x].length = 0;
  219. dma[x].sosf = 0;
  220. dma[x].eof = 0;
  221. dma[x].owner = 1;
  222. dma[x].buf = (buffer + size * x);
  223. dma[x].empty = (uint32_t)&dma[(x + 1) % count];
  224. }
  225. return dma;
  226. }
  227. static esp_err_t cam_dma_config(const camera_config_t *config)
  228. {
  229. bool ret = ll_cam_dma_sizes(cam_obj);
  230. if (0 == ret) {
  231. return ESP_FAIL;
  232. }
  233. cam_obj->dma_node_cnt = (cam_obj->dma_buffer_size) / cam_obj->dma_node_buffer_size; // Number of DMA nodes
  234. cam_obj->frame_copy_cnt = cam_obj->recv_size / cam_obj->dma_half_buffer_size; // Number of interrupted copies, ping-pong copy
  235. ESP_LOGI(TAG, "buffer_size: %d, half_buffer_size: %d, node_buffer_size: %d, node_cnt: %d, total_cnt: %d",
  236. cam_obj->dma_buffer_size, cam_obj->dma_half_buffer_size, cam_obj->dma_node_buffer_size, cam_obj->dma_node_cnt, cam_obj->frame_copy_cnt);
  237. cam_obj->dma_buffer = NULL;
  238. cam_obj->dma = NULL;
  239. cam_obj->frames = (cam_frame_t *)heap_caps_calloc(1, cam_obj->frame_cnt * sizeof(cam_frame_t), MALLOC_CAP_DEFAULT);
  240. CAM_CHECK(cam_obj->frames != NULL, "frames malloc failed", ESP_FAIL);
  241. uint8_t dma_align = 0;
  242. size_t fb_size = cam_obj->fb_size;
  243. if (cam_obj->psram_mode) {
  244. dma_align = ll_cam_get_dma_align(cam_obj);
  245. if (cam_obj->fb_size < cam_obj->recv_size) {
  246. fb_size = cam_obj->recv_size;
  247. }
  248. }
  249. /* Allocate memory for frame buffer */
  250. size_t alloc_size = fb_size * sizeof(uint8_t) + dma_align;
  251. uint32_t _caps = MALLOC_CAP_8BIT;
  252. if (CAMERA_FB_IN_DRAM == config->fb_location) {
  253. _caps |= MALLOC_CAP_INTERNAL;
  254. } else {
  255. _caps |= MALLOC_CAP_SPIRAM;
  256. }
  257. for (int x = 0; x < cam_obj->frame_cnt; x++) {
  258. cam_obj->frames[x].dma = NULL;
  259. cam_obj->frames[x].fb_offset = 0;
  260. cam_obj->frames[x].en = 0;
  261. ESP_LOGI(TAG, "Allocating %d Byte frame buffer in %s", alloc_size, _caps & MALLOC_CAP_SPIRAM ? "PSRAM" : "OnBoard RAM");
  262. cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps);
  263. CAM_CHECK(cam_obj->frames[x].fb.buf != NULL, "frame buffer malloc failed", ESP_FAIL);
  264. if (cam_obj->psram_mode) {
  265. //align PSRAM buffer. TODO: save the offset so proper address can be freed later
  266. cam_obj->frames[x].fb_offset = dma_align - ((uint32_t)cam_obj->frames[x].fb.buf & (dma_align - 1));
  267. cam_obj->frames[x].fb.buf += cam_obj->frames[x].fb_offset;
  268. ESP_LOGI(TAG, "Frame[%d]: Offset: %u, Addr: 0x%08X", x, cam_obj->frames[x].fb_offset, (uint32_t)cam_obj->frames[x].fb.buf);
  269. cam_obj->frames[x].dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->frames[x].fb.buf);
  270. CAM_CHECK(cam_obj->frames[x].dma != NULL, "frame dma malloc failed", ESP_FAIL);
  271. }
  272. cam_obj->frames[x].en = 1;
  273. }
  274. if (!cam_obj->psram_mode) {
  275. cam_obj->dma_buffer = (uint8_t *)heap_caps_malloc(cam_obj->dma_buffer_size * sizeof(uint8_t), MALLOC_CAP_DMA);
  276. if(NULL == cam_obj->dma_buffer) {
  277. ESP_LOGE(TAG,"%s(%d): DMA buffer %d Byte malloc failed, the current largest free block:%d Byte", __FUNCTION__, __LINE__,
  278. cam_obj->dma_buffer_size, heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
  279. return ESP_FAIL;
  280. }
  281. cam_obj->dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->dma_buffer);
  282. CAM_CHECK(cam_obj->dma != NULL, "dma malloc failed", ESP_FAIL);
  283. }
  284. return ESP_OK;
  285. }
  286. esp_err_t cam_init(const camera_config_t *config)
  287. {
  288. CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG);
  289. esp_err_t ret = ESP_OK;
  290. cam_obj = (cam_obj_t *)heap_caps_calloc(1, sizeof(cam_obj_t), MALLOC_CAP_DMA);
  291. CAM_CHECK(NULL != cam_obj, "lcd_cam object malloc error", ESP_ERR_NO_MEM);
  292. cam_obj->swap_data = 0;
  293. cam_obj->vsync_pin = config->pin_vsync;
  294. cam_obj->vsync_invert = true;
  295. ll_cam_set_pin(cam_obj, config);
  296. ret = ll_cam_config(cam_obj, config);
  297. CAM_CHECK_GOTO(ret == ESP_OK, "ll_cam initialize failed", err);
  298. #if CAMERA_DBG_PIN_ENABLE
  299. PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[DBG_PIN_NUM], PIN_FUNC_GPIO);
  300. gpio_set_direction(DBG_PIN_NUM, GPIO_MODE_OUTPUT);
  301. gpio_set_pull_mode(DBG_PIN_NUM, GPIO_FLOATING);
  302. #endif
  303. ESP_LOGI(TAG, "cam init ok");
  304. return ESP_OK;
  305. err:
  306. free(cam_obj);
  307. cam_obj = NULL;
  308. return ESP_FAIL;
  309. }
  310. esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint16_t sensor_pid)
  311. {
  312. CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG);
  313. esp_err_t ret = ESP_OK;
  314. ret = ll_cam_set_sample_mode(cam_obj, (pixformat_t)config->pixel_format, config->xclk_freq_hz, sensor_pid);
  315. cam_obj->jpeg_mode = config->pixel_format == PIXFORMAT_JPEG;
  316. #if CONFIG_IDF_TARGET_ESP32
  317. cam_obj->psram_mode = false;
  318. #else
  319. cam_obj->psram_mode = (config->xclk_freq_hz == 16000000);
  320. #endif
  321. cam_obj->frame_cnt = config->fb_count;
  322. cam_obj->width = resolution[frame_size].width;
  323. cam_obj->height = resolution[frame_size].height;
  324. if(cam_obj->jpeg_mode){
  325. cam_obj->recv_size = cam_obj->width * cam_obj->height / 5;
  326. cam_obj->fb_size = cam_obj->recv_size;
  327. } else {
  328. cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel;
  329. cam_obj->fb_size = cam_obj->width * cam_obj->height * cam_obj->fb_bytes_per_pixel;
  330. }
  331. ret = cam_dma_config(config);
  332. CAM_CHECK_GOTO(ret == ESP_OK, "cam_dma_config failed", err);
  333. cam_obj->event_queue = xQueueCreate(cam_obj->dma_half_buffer_cnt - 1, sizeof(cam_event_t));
  334. CAM_CHECK_GOTO(cam_obj->event_queue != NULL, "event_queue create failed", err);
  335. size_t frame_buffer_queue_len = cam_obj->frame_cnt;
  336. if (config->grab_mode == CAMERA_GRAB_LATEST && cam_obj->frame_cnt > 1) {
  337. frame_buffer_queue_len = cam_obj->frame_cnt - 1;
  338. }
  339. cam_obj->frame_buffer_queue = xQueueCreate(frame_buffer_queue_len, sizeof(camera_fb_t*));
  340. CAM_CHECK_GOTO(cam_obj->frame_buffer_queue != NULL, "frame_buffer_queue create failed", err);
  341. ret = ll_cam_init_isr(cam_obj);
  342. CAM_CHECK_GOTO(ret == ESP_OK, "cam intr alloc failed", err);
  343. #if CONFIG_CAMERA_CORE0
  344. xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0);
  345. #elif CONFIG_CAMERA_CORE1
  346. xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1);
  347. #else
  348. xTaskCreate(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle);
  349. #endif
  350. ESP_LOGI(TAG, "cam config ok");
  351. return ESP_OK;
  352. err:
  353. cam_deinit();
  354. return ESP_FAIL;
  355. }
  356. esp_err_t cam_deinit(void)
  357. {
  358. if (!cam_obj) {
  359. return ESP_FAIL;
  360. }
  361. cam_stop();
  362. if (cam_obj->task_handle) {
  363. vTaskDelete(cam_obj->task_handle);
  364. }
  365. if (cam_obj->event_queue) {
  366. vQueueDelete(cam_obj->event_queue);
  367. }
  368. if (cam_obj->frame_buffer_queue) {
  369. vQueueDelete(cam_obj->frame_buffer_queue);
  370. }
  371. if (cam_obj->dma) {
  372. free(cam_obj->dma);
  373. }
  374. if (cam_obj->dma_buffer) {
  375. free(cam_obj->dma_buffer);
  376. }
  377. if (cam_obj->frames) {
  378. for (int x = 0; x < cam_obj->frame_cnt; x++) {
  379. free(cam_obj->frames[x].fb.buf - cam_obj->frames[x].fb_offset);
  380. if (cam_obj->frames[x].dma) {
  381. free(cam_obj->frames[x].dma);
  382. }
  383. }
  384. free(cam_obj->frames);
  385. }
  386. ll_cam_deinit(cam_obj);
  387. free(cam_obj);
  388. cam_obj = NULL;
  389. return ESP_OK;
  390. }
  391. void cam_stop(void)
  392. {
  393. ll_cam_vsync_intr_enable(cam_obj, false);
  394. ll_cam_stop(cam_obj);
  395. }
  396. void cam_start(void)
  397. {
  398. ll_cam_vsync_intr_enable(cam_obj, true);
  399. }
  400. camera_fb_t *cam_take(TickType_t timeout)
  401. {
  402. camera_fb_t *dma_buffer = NULL;
  403. TickType_t start = xTaskGetTickCount();
  404. xQueueReceive(cam_obj->frame_buffer_queue, (void *)&dma_buffer, timeout);
  405. if (dma_buffer) {
  406. if(cam_obj->jpeg_mode){
  407. // find the end marker for JPEG. Data after that can be discarded
  408. int offset_e = cam_verify_jpeg_eoi(dma_buffer->buf, dma_buffer->len);
  409. if (offset_e >= 0) {
  410. // adjust buffer length
  411. dma_buffer->len = offset_e + sizeof(JPEG_EOI_MARKER);
  412. return dma_buffer;
  413. } else {
  414. ESP_LOGW(TAG, "NO-EOI");
  415. cam_give(dma_buffer);
  416. return cam_take(timeout - (xTaskGetTickCount() - start));//recurse!!!!
  417. }
  418. } else if(cam_obj->psram_mode && cam_obj->in_bytes_per_pixel != cam_obj->fb_bytes_per_pixel){
  419. //currently this is used only for YUV to GRAYSCALE
  420. dma_buffer->len = ll_cam_memcpy(cam_obj, dma_buffer->buf, dma_buffer->buf, dma_buffer->len);
  421. }
  422. return dma_buffer;
  423. } else {
  424. ESP_LOGW(TAG, "Failed to get the frame on time!");
  425. }
  426. return NULL;
  427. }
  428. void cam_give(camera_fb_t *dma_buffer)
  429. {
  430. for (int x = 0; x < cam_obj->frame_cnt; x++) {
  431. if (&cam_obj->frames[x].fb == dma_buffer) {
  432. cam_obj->frames[x].en = 1;
  433. break;
  434. }
  435. }
  436. }