soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / camera / cros_camera.c
blobff3967803301ec69089487de35d8ec71d19600d6
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <crc_byte.h>
5 #include <string.h>
7 #include "cros_camera.h"
9 int check_cros_camera_info(const struct cros_camera_info *info)
11 if (memcmp(info->magic, CROS_CAMERA_INFO_MAGIC, sizeof(info->magic))) {
12 printk(BIOS_ERR, "Invalid magic in camera info\n");
13 return -1;
16 const uint8_t *ptr = (void *)(&info->crc16 + 1);
17 uint16_t crc16 = 0;
18 while (ptr < (uint8_t *)info + sizeof(struct cros_camera_info))
19 crc16 = crc16_byte(crc16, *ptr++);
21 if (info->crc16 != crc16) {
22 printk(BIOS_ERR, "Incorrect CRC16: expected %#06x, got %#06x\n",
23 crc16, info->crc16);
24 return -1;
27 if (info->version != CROS_CAMERA_INFO_VERSION) {
28 printk(BIOS_ERR, "Unknown camera info version: %u\n",
29 info->version);
30 return -1;
32 if (info->size < CROS_CAMERA_INFO_SIZE_MIN) {
33 printk(BIOS_ERR, "Size of camera info is too small: %u\n",
34 info->size);
35 return -1;
38 return 0;